我更改了 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/