JQuery and select all checkboxes
-
Hi everyboby. I ‘ve got a problem with JQuery and a select all checkboxes function .
The function work well only if i insert a script tag with JQuery library in the page. but the JQuery file is already inserted in the HEAD tag with an ID id=”jquery-core-js”.
<script src='https:// .../js/jquery/jquery.min.js?ver=3.6.1' id=jquery-core-js></script> <script src='https://.../js/jquery/jquery-migrate.min.js?ver=3.3.2' id=jquery-migrate-js></script>
Is there something wrong in my function ? Why do I have to insert the library twice?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script> $(document).ready(function(){ $('#fld_4720906_1_opt1999183').on('click',function(){ if(this.checked){ $('.fld_6260799_1').each(function(){ this.checked = true; }); }else{ $('.fld_6260799_1').each(function(){ this.checked = false; }); } }); $('.fld_6260799_1').on('click',function(){ if($('.fld_6260799_1:checked').length == $('.fld_6260799_1').length){ $('#fld_4720906_1_opt1999183').prop('checked',true); }else{ $('#fld_4720906_1_opt1999183').prop('checked',false); } }); }); </script>
Can somebody explain me what’s wrong here… Thanks.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘JQuery and select all checkboxes’ is closed to new replies.