问题描述
||
我有一张桌子,一旦我添加一行,它的背景颜色就会改变以显示更改(突出显示会很好)。这是我在做什么
$(\"#tableDg tbody tr:first\").css(\"background-color\",\"red\")
所以为了延误工作,我做了
$(\"#tableDg tbody tr:first\").css(\"background-color\",\"red\").delay(2000).css(\"background-color\",\"aqua\");
但是除了延迟它之外,它还只是将bkg颜色绘制为aqua,我对此有何评论?谢谢
解决方法
$(\"#tableDg tbody tr:first\").css(\"background-color\",\"red\");
setTimeout(function() {
$(\"#tableDg tbody tr:first\").css(\"background-color\",\"aqua\");
},2000);
要添加高光效果:
$(\"#tableDg tbody tr:first\").css(\"background-color\",\"aqua\").effect(\"highlight\",{},3000);
},2000);
或这个:
$(\"#tableDg tbody tr:first\").css(\"background-color\",\"aqua\");
$(\'#tableDg tbody tr:first\').effect(\"highlight\",2000);
, 也许这会有所帮助:
我向该行添加了一个data属性以突出显示我想要的那个,因此我将其命名为data-id。
获取原始背景色
动画以突出显示颜色
等待500毫秒
设置为原始颜色(淡出)
删除样式,以便样式表可以正常工作。
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
},\'swing\',function () {
$(\'#myTable tbody tr[data-id=\"\' + id + \'\"]\').removeAttr(\"style\");
});
, 如果需要一个延迟,则应使用use6ѭ