Hello I want to convert the following to pure JS if possible.
My ultimate goal is to display the var "bar" if checkboxes with id's ("checkbox1", "checkbox2", "checkbox3") are selected + display corresponding id's ("item1", "item2", "item3").
$('input:checkbox').change(function () {
if ($(this).is(':checked')) {
switch (this.id){
case 'checkbox1':
bar.show();
item1.show();
break;
case 'checkbox2':
bar.show();
item2.show();
break;
case 'checkbox3':
bar.show();
item3.show();
break;
default:
bar.hide();
}
} else {
bar.hide();
}
});
How can i simply do this?
Aucun commentaire:
Enregistrer un commentaire