I have a table in where once i add a row, its background color changes to show the changes (highlight will be good). Here is what i am doing
$("#tableDg tbody tr:first").css("background-color", "red")
So in order for the delay to work i did
$("#tableDg tbody tr:first").css("background-color", "red").delay(2000).css("background-color", "aqua");
but instead of delaying it just paints the bkg color to aqua, any comments what can i do here? Thanks
$("#tableDg tbody tr:first").css("background-color", "red");
setTimeout(function() {
$("#tableDg tbody tr:first").css("background-color", "aqua");
}, 2000);
To Add the highlight effect:
$("#tableDg tbody tr:first").css("background-color", "red");
setTimeout(function() {
$("#tableDg tbody tr:first").css("background-color", "aqua").effect("highlight", {}, 3000);
}, 2000);
Or this:
$("#tableDg tbody tr:first").css("background-color", "red");
setTimeout(function() {
$("#tableDg tbody tr:first").css("background-color", "aqua");
$('#tableDg tbody tr:first').effect("highlight", {}, 3000);
}, 2000);
Maybe this will help: I added a data attribute to the row to highlight the one I want, so I named it data-id.
Remove the style so the stylesheet can make its work.
var highlight_color = "#fbec88";
var original_color = $('#myTable tbody tr[data-id="' + id + '"]').css("background-color");
$('#myTable tbody tr[data-id="' + id + '"]')
.animate({
'background-color': highlight_color
}, 'slow', 'swing')
.delay(500)
.animate({
'background-color': original_color
}, 'slow', 'swing', function () {
$('#myTable tbody tr[data-id="' + id + '"]').removeAttr("style");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With