first thanks for your help in advance. I'm pretty newbie in jquery and javascript and I don't speak so much english so i cound't found nothing liked in my research.
This is my html
<li></li>
<li></li>
<li id="user1"></li>
<input type="checkbox" id="checkbox1">
<li></li>
<li></li>
<li id="user2"></li>
<input type="checkbox" id="checkbox2">
I want to everytime that a checkbox with id ("checkbox"+i) is checked I toggle a class in the ("user"+i) to push in a list and then send with post request.
I tryed this
for(i = 1; i < 3; i++) {
document.getElementById('checkbox' + i).addEventListener('change', function() {
document.getElementById('user' + i).setAttribute("class", "passInterestIds");
});
}
but it only gives me user3 independent of the checkbox
How can I Make this work?
Aucun commentaire:
Enregistrer un commentaire