gpt4 book ai didi

javascript - Twitter Bootstrap Tabs : Show on Hover, 隐藏在 onmouseout 上

转载 作者:行者123 更新时间:2023-11-29 22:24:16 25 4
gpt4 key购买 nike

我更改了 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 Tabs : Show on Hover, 隐藏在 onmouseout 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10538874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com