我只想在悬停后更改行的背景颜色(意思是......我在每一行上都有一个工具提示。我想在查看工具提示文本后更改颜色)1 或 2秒。如何做到这一点?使用我当前的代码,1 秒后我的鼠标光标触及的所有行的颜色都会发生变化
使用我当前的代码,1 秒后鼠标光标触及的所有行的颜色都会发生变化
当前代码:
$('#table_id tr td').hover(function() {
var self = this;
setTimeout(function() {
$(self).parent('tr').addClass('blueBgColor');
}, 2000);
});
最佳答案
我已经使用 setTimeout 函数来完成您的任务...
var timer, thisid;
$('td').mouseenter(function(){
thisid = $(this);
timer = setTimeout(function(){
$(thisid).parent('tr').addClass('blueBgColor');
},2000);
}).mouseleave(function(){
clearTimeout(timer);
});
为了您的引用,检查这个FIDDLE
关于jquery/css : I want to change the bgcolor of row only after hovering for 1 or 2 seconds. 如何实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25160724/