I have dynamic grid-based tables in the application I am developing.
The following code works, but I need a little functionality added to it:
Current script does the following:
- script sees first checkbox.
- click first checkbox selects/deselects all checkboxes within the closest table.
New functionality wanted:
- script sees first checkbox.
- click first checkbox selects/deselects all checkboxes within the closest table.
- select/deselect individual checkboxes in table
here is the jquery:
<script type="text/javascript">
$(document).ready(function(){
//this code works for select ALL, but not individual checkbox select/deselect;
$('td input:checkbox').click(function(e) {
var table = $(e.target).closest('table');
$('td input:checkbox', table).attr('checked', e.target.checked);
});
});
</script>
ok i figured it out after futsing with it for waaaaay too long:
i added classes to the two different checkboxes and referenced them in the jquery.