[jQuery] check/uncheck via toggle
<html>
<body>
Hello folks,
I have a table of data, with each row containing a checkbox. What I
want users to be able to do is tick the box of each row of data they want
to delete (and after ticking, they will submit the form etc etc.
As a visual aid, I want to alter the background colour of the row - and
if they untick a selection, to reverse that background colour
change.
My code as follows achieves the background colour toggle, but the
checkboxes are neither checked or unchecked.
I'd appreciate someone pointing out my error?
<tt>$('input[@type=checkbox]').toggle(
function() {
$(this).attr('checked',true);
$(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#FFF'},1000);
},<x-tab> </x-tab>
function() {
$(this).attr('checked',false);
$(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#E0F88F'},1000);
}
);<x-tab> </x-tab>
</tt>Thanks
Bruce</body>
</html>