Reputation: 12512
I have a table with multiple rows. Each row has a check button. How do i highlight the row (apply style I suppose) when the checkbox is selected?
Upvotes: 3
Views: 4532
Reputation: 3581
$(function(){
$(":checkbox").click(function(){
var thischeck = $(this);
var approved = (thischeck.is(':checked')) ? '1' : '0';
if(approved) {
//apply what ever you want
}
});
})(jQuery);
I would try this, not sure if it is an elegant solution.
Upvotes: 0
Reputation: 652
$(":checkbox:checked").each(
function()
{
if (this.checked)
{
this.addclass("yourClass");
}
}
Upvotes: 0
Reputation: 342775
$(":checkbox").change(function() {
$(this).closest("tr").toggleClass("highlight", this.checked);
});
See toggleClass(
) and closest()
Upvotes: 10