I'm using the following code and it does toggle my check boxes, but not correctly.
It has an issue if the check box has been manually set as checked.
The when you run the code it checks the boxes, but then you click it again it only unchecked the ones that weren't previously checked.
$(".all").click(function(e) {
var checked = !$(this).data('checked');
$('.trigger').attr('checked', checked);
$(this).data('checked', checked);
});
I'm using an input type='image'
as my element to run the checking from.
<input type="image" class="all" title="All" src="toggle.png"/>
I've tried using the following, but when that runs it unchecks the checkboxes and then removes the image i'm using to call it.
$('.all').toggle(function(){
$('input:checkbox').attr('checked','checked');
},function(){
$('input:checkbox').removeAttr('checked');
})
Can anyone advise how I can do this correctly.
Thanks