javascript - Twitter Bootstrap 选项卡 : Show on Hover, 在 onmouseout 时隐藏

标签 javascript jquery css hover twitter-bootstrap

我更改了 bootstrab.js (只是用悬停替换了单击):

  $(function () {
    $('body').on('hover.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
      e.preventDefault()
      $(this).tab('show')
    })
  })

现在我希望当您未将鼠标悬停在选项卡或内容上时关闭内容选项卡。

我该怎么做?

最佳答案

更新:如下所示

var timer;

$('tab_element').hover(
    function(){ //hover
        // clear timer first
        clearTimeout(timer);
        // then show the content
    },
    function(){ //unhovered, 1000 milliseconds
        // set a timer to call the hide function
        timer = setTimeout("hide_function", 1000);
    }
);

$('content_tab_here').bind('mouseleave', function(){
    // hide it, you can set a timer here too if you want
});

这是关于计时器的文档 http://www.w3schools.com/js/js_timing.asp 这里有很多选项,但这将帮助您入门,我使用的 jquery 是老式的,所以如果您使用的是最新版本的 jquery,您可以相应地更改代码。我不想为你写出所有内容,因为那样你就无法学习,而我也没有那么多时间,因为我在工作。祝你好运。

关于javascript - Twitter Bootstrap 选项卡 : Show on Hover, 在 onmouseout 时隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10538874/

相关文章:

javascript - 在函数内的 if 语句中调用变量

javascript - 数组更改时 VueJS dom 不刷新

jquery - 深入研究 JSON

php - jQuery - 每 10 秒调用一次 ajax

javascript - 使用 jquery 计算空或非空 TD

javascript - 在 JavaScript 中生成格式正确的 SSH key

javascript - 无法使用addChild方法

jquery - 如何解决数据表中 Shiny 的错位问题?

html - Firefox 中表格的最小高度不起作用

html - 为什么我的 bootstrap 列重叠?