I am a begginer in this field, and still learning. I tried to do a 'Todo' list, and have the following code written (used JQuery). I can add items to the list (all items have 2 buttons of its own)
I can not make the list item buttons to work. One is a checkbox type, witch should change the color of the text of that item. The second button should delete the item from the list (with the buttons for that item too)
Could somone help me to make this code work?
$(document).ready(function(){
$('#add').click(() => {
let listaInput = $('#szovegDoboz').val()
$("ul").append(
`<li>
<span>
<p class = "listaElem">${listaInput}</p>
<p>
<button class = "myButton"><img src = "./content/del.svg" width = "20px" height = "20px"></button>
<input type = "checkbox"/>
</p>
</span>
</li>`)
})
$('input[type="checkbox"]').on('change', 'li', function() {
if (this.checked) {
$(this).css('color', 'gainsboro')
}
else {
$(this).css('color', 'dimgray')
}
})
$('.mybutton').on('click', 'li', function() {
$(this).remove('li')
})
})