[英]Twitter Bootstrap manually close tabs
Got it working now. 现在工作了。 Script snippet was wrong and was not even called somehow.
脚本片段是错误的,甚至没有以某种方式被调用。
For future reference -> to close bootstrap tabs: 供以后参考->关闭引导程序选项卡:
</script>
$("#closetab").click(function() {
$("#myTabContent").hide();
});
</script>
<a href="#" id="closetab">Close</a>
And be careful when using center-TAGs for anchor texts. 在将中心标记用于锚文本时,请务必小心。 It screws with your js/jquery when pointing to IDs of content within the center TAG.
当指向中心TAG中的内容ID时,它将与您的js / jquery拧在一起。
Im using Bootstrap Tabs ( http://twitter.github.com/bootstrap/javascript.html#tabs ) with a slightly changed bootstrap-tab.js to show tabs on hover: 我将Bootstrap选项卡( http://twitter.github.com/bootstrap/javascript.html#tabs )与经过稍微更改的bootstrap-tab.js一起使用以在悬停时显示选项卡:
$(function () {
$('body').on('hover.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault()
$(this).tab('show')
})
})
Now i want to add a way to manually close those tabs. 现在,我想添加一种手动关闭这些选项卡的方法。 I found a code snippet somewhere that does the trick in Chrome/Mozilla/Opera but not in IE:
我在Chrome / Mozilla / Opera中找到了能解决问题的代码片段, 但在IE中却找不到:
<script>
$('a[href="#closetab"]').on('click',function(){
$("#flyout_tab").hide();
});
</script>
and 和
<a href="" id="closetab">Close</a>
In IE when i click the close-button it sends me to the root of the directoy the site is in. 在IE中,当我单击关闭按钮时,它会将我发送到该站点所在目录的根目录。
I guess it has something to do with the way IE handles empty a href's (a href=""). 我猜想这与IE处理空href(a href =“”)的方式有关。 When i put something like a href="#" it wont work in any browser.
当我放置诸如href =“#”之类的内容时,它将无法在任何浏览器中使用。
Try putting "closetab" in the href property like this: 尝试像这样在href属性中放入“ closetab”:
<a href="#closetab">Close</a>
Since the above code doesn't work, try changing the script to: 由于上述代码无效,请尝试将脚本更改为:
<script>
$('#closetab').on('click',function(){
$("#flyout_tab").hide();
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.