Using MVC 5 and Bootstrap 3
I am trying to make a table row red, but due to my table having the table-hover
class, the table-hover affect turns the row back to the initial color on a mouseover. I want to temporarily overrule that effect for my script.
function deleteFunction(element) {
var newID = $(element).closest("td").find("span.ID").text();
$(element).closest("tr").css('background-color', 'red');
$(document).ready(function () {
var answer = confirm("Are you sure you want to delete this movie?");
if (answer) {
$.post(
'@Url.Action("customDelete", "Movie")',
{
'id': newID
},
function (data) { },
"json"
);
$(element).closest("tr").remove();
return true;
} else {
$(element).closest("tr").css('background-color', 'initial');
return false;
}
});
}
these two items need the !important, but I am not sure how to do this in JQuery
$(element).closest("tr").css('background-color', 'red');
$(element).closest("tr").css('background-color', 'initial');
EDIT - ANSWER
The reason I could not get this to work was because my table was using table-hover
, to fix this I had to toggle the hover class on and off.
$(element).closest("table").toggleClass("table-hover");