Hello. It is necessary to check whether the checkbox is checked on the page and remove the attribute from submit - disabled.

<input type="checkbox" id="check" name="mods[]"> <input type="checkbox" id="check" name="mods[]"> <input type="checkbox" id="check" name="mods[]"> <input type="checkbox" id="check" name="mods[]"> <input type="checkbox" id="check" name="mods[]"> <input type="submit" class="but" disabled="disabled"> $('#check:input:checkbox').click(function(){ if($(this).prop("checked") == true){ $('.but').removeAttr('disabled'); }else{ $('.but').attr('disabled', true); } }); 

The code works only on 1 checkbox, i.e. Clicking on 2 and the following will not happen. How to make the code work on all checkbox.

Why can not I use class="check" , they are busy and change depending on the category

Why can not I use input:checkbox , there are other checkbox on the page

  • "Within the same page, it CAN NOT be two or more elements with the same ID!" It is framed and hang over the workplace. - Deonis
  • I know, just added for clarity - innot20
  • @ innot20, For ... clarity ??? Even afraid to learn the explanation :) - user31688

2 answers 2

ID is unique, if that, learn mana.
So?

  • Can be easier - jsfiddle.net/y6jqgj75/1 - Deonis
  • I love functional programming, but it’s definitely not for beginners who don’t even know the basics, that's why I wrote it. - user31688
 <input type="checkbox" class="123123 check" name="mods[]"> <input type="checkbox" class="dffd check" name="mods[]"> <input type="checkbox" class="adfsd check" name="mods[]"> <input type="checkbox" class="hfh check" name="mods[]"> <input type="checkbox" class="sdfasd check" name="mods[]"> <input type="submit" class="but" disabled="disabled"> $('.check:input:checkbox').click(function(){ if($(this).prop("checked") == true){ $('.but').removeAttr('disabled'); }else{ $('.but').attr('disabled', true); } }); 

Did not know that you can register two classes