0

I don't know why this code doesn't work for me: the result is name1 - box5. I want it like this:

name1 - box1
name2 - box2
name3 - box3
...

This is my code:

$(document).ready(function() {  

for (var i = 1; i < 5; i++) {
document.querySelector('#name' + i).addEventListener('click', ()=>{
document.querySelector('#box' + i).checked=true
});
}   
    
}); 
Sara Z
  • 625
  • 7
  • 18

0 Answers0