简体   繁体   English

jQuery Javascript背景颜色更改/突出显示

[英]JQuery Javascript background colour change/highlight

Can you do a simple table row change bg colour for x seconds then change back in pure Javascript or JQuery? 您能做一个简单的表行更改bg颜色x秒钟,然后以纯Javascript或JQuery更改回来吗?

What I've tried doesn't seem to work, and I'd rather avoid the use of any further plugins seeing as I've done everything else in JQuery or Javascript alone. 我尝试过的方法似乎不起作用,我宁愿避免使用任何其他插件,因为我仅在JQuery或Javascript中完成了其他所有工作。

What I'm after is a flash/ short highlight effect. 我需要的是闪光灯/短高光效果。

$('tr.yourRow').css({'background-color': 'red'});

setTimeout(function(){
   $('tr.yourRow').css({'background-color': 'blue'});
}, 6000);

Headshota's method will work. Headshota的方法将起作用。 here is an alternative way. 这是另一种方法。

$('#yourelementid').addClass('backgroundClass').delay(5000).queue(function(){$('#yourelementid').removeClass('backgroundClass');});

And then define a CSS class 然后定义一个CSS类

.backgroundClass { background:blue;}

Demo 演示版

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM