I'm working with a table that has rows categorized by different classes based on their color. When a button is clicked, I want the row's background color to change instantly. I've attempted using both the .addClass()
and .css()
methods without success. However, my function to determine if the row is colored or not is functioning properly when triggered by a click event.
Below are the code snippets I am utilizing, along with the corresponding CSS classes for the rows:
If the row is currently white:
$("#"+table+"_row_"+id).addClass("table-1").removeClass("table-0");
or
$("#"+table+"_row_"+id).css("background-color","orange");
If the row is currently orange:
$("#"+table+"_row_"+id).addClass("table-0").removeClass("table-1");
or
$("#"+table+"_row_"+id).css("background-color","white");
CSS:
table.tablesorter .table-1{
background-color:orange;
}
table.tablesorter .table-0{
background-color:white;
}