mercredi 24 février 2016

How to target only the ID in the div with addClass on a checkbox

I am trying to only target the div associated with the checkbox. Right now the script I am using only changes the class of the first div with the ID of taskList instead of the one where the checkbox is located.

$('input:checkbox').change(function(){
if($(this).is(":checked")) {
    $('#taskList').addClass("complete");
} else {
    $('#taskList').removeClass("complete");
}
});




Aucun commentaire:

Enregistrer un commentaire