Reputation: 3163
I am trying to highlight a table row with a specific item ID (in first column) by updating its CSS class, but it is not working:
.inactive {
background-color: "red";
}
My code calls the following JavaScript function whenever a specific event happens:
function highlight_item(item_id){
var tableRow = $("#itemsTable tr td:first-child").filter(function() {
return $(this).text() == item_id
}).parent();
tableRow.addClass("inactive")
}
Strangely, it works if I replace the addClass()
call with
tableRow.css("backgroundColor", "red")
What I am doing wrong here?
Upvotes: 1
Views: 68
Reputation: 14413
Remove the quotes from "red". Use .inactive { background-color: red; }
Upvotes: 3