[jQuery] toggle check box on row click
I have a table and each row has the id of the data element. I put a
checkbox in the the first cell of every row with an id of cb+OrderId.
I found my answer to click on a row and check the checkbox but I was
just wondering if there was a better way. Is there a way to use this
to get the checkbox?
$(document).ready(function(){
$("#dt tbody tr")
.hover( function(e) {
$(this).addClass("rowHighlight");
},
function(e) {
$(this).removeClass("rowHighlight");
})
.click( function(e) {
var id = $(this).attr("id");
$("#cb"+id).toggleCheck();
});
});
$.fn.toggleCheck = function() {
return this.each(function() {
this.checked = !this.checked;
});
};