jquery/css : I want to change the bgcolor of row only after hovering for 1 or 2 seconds. 如何实现?

标签 jquery css hoverintent

我只想在悬停后更改行的背景颜色(意思是......我在每一行上都有一个工具提示。我想在查看工具提示文本后更改颜色)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/

相关文章:

javascript - jQuery 多选下拉菜单,带有所选项目的关闭按钮

html - 悬停触摸屏

html - 将元素符号图标更改为双引号

javascript - 将 Hoverintent 应用于 Jquery 悬停

javascript - 航点.js : check if element is in view on page load

javascript - 在 Backbone.js 中使用什么来代替 "this"?

javascript - 根据搜索字段值触发按钮上的工具提示

html - 如何防止 div 中的 float 中断? ( Bootstrap )

jquery - 水平子导航查询

javascript - 如何使用 Raphaël.js 制作路径填充动画?