samedi 20 janvier 2018

Adding/removing class to parent element while clicking on checkbox

I have simple list with <input type='checkbox'> inside every li. Few of them are checked and other not

<ul>
<li><input type='checkbox' checked></li>
<li><input type='checkbox'></li>
<li><input type='checkbox' checked></li>
<li><input type='checkbox'></li>
</ul>

How can I add class .transparent to those li that contains <input type='checkbox'> that is not checked and remove this class when user will mark <input type='checkbox'> as checked?

The main problem is that I want to add/remove this class (1) when page is loading and (2) change it later while user will click something on my list.




Aucun commentaire:

Enregistrer un commentaire