如何突出显示第一行表格2秒钟并返回原始状态

abi*_*964 5 jquery

我有一张桌子,一旦我添加一行,它的背景颜色会改变以显示变化(突出显示会很好).这就是我在做的事情

$("#tableDg tbody tr:first").css("background-color", "red")
Run Code Online (Sandbox Code Playgroud)

所以为了延迟工作我做了

$("#tableDg tbody tr:first").css("background-color", "red").delay(2000).css("background-color", "aqua");
Run Code Online (Sandbox Code Playgroud)

但不是推迟它只是将bkg颜色描绘成浅绿色,任何评论我能在这做什么?谢谢

Raz*_*orm 10

$("#tableDg tbody tr:first").css("background-color", "red");

setTimeout(function() {
    $("#tableDg tbody tr:first").css("background-color", "aqua");
}, 2000);
Run Code Online (Sandbox Code Playgroud)

要添加高光效果:

$("#tableDg tbody tr:first").css("background-color", "red");

setTimeout(function() {
    $("#tableDg tbody tr:first").css("background-color", "aqua").effect("highlight", {}, 3000);
}, 2000);
Run Code Online (Sandbox Code Playgroud)

或这个:

$("#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);
Run Code Online (Sandbox Code Playgroud)