I just want to check all the checkboxes on the page if the user clicks the "Select All" button.
In body:
<button id="checkall">Select All</button>
JQuery
<head> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#checkall').click(function () { $("input[type=checkbox]").each( function() { $(this).attr('checked', true); }); }); </script> </head>
And the flags are generated by a small amount of php:
echo '<li>'; echo '<input type="checkbox" name="checkbox[]" value="'.$x.'" />'.$x.'<br/>'; echo '</li>';
Can someone tell me what I am doing wrong?
Tim h source share