Jquery 如何手动激活Twitter引导选项卡
使用Twitter Bootstrap的[Tabbable Tabs][1],它说: “通过javascript启用选项卡式选项卡(每个选项卡需要单独激活)”: 然后您可以“以多种方式激活各个选项卡”:Jquery 如何手动激活Twitter引导选项卡,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,使用Twitter Bootstrap的[Tabbable Tabs][1],它说: “通过javascript启用选项卡式选项卡(每个选项卡需要单独激活)”: 然后您可以“以多种方式激活各个选项卡”: 当我单击每个选项卡并使其id显示在URL中时,如何单独激活每个选项卡?这是在URL中添加哈希,您可以添加以下内容: $('a').click(function(e){ e.preventDefault(); if(window.location.hash) window.location.ha
当我单击每个选项卡并使其id显示在URL中时,如何单独激活每个选项卡?这是在URL中添加哈希,您可以添加以下内容:
$('a').click(function(e){
e.preventDefault();
if(window.location.hash) window.location.hash = '';
window.location.hash = $(e.target).attr('class'); //or id, or other attribute
});
当用户单击“a”标记(或您的选项卡id等)时,请删除previus哈希并附加新哈希。
基本上使用window.location.hash。让hash正确显示在位置url中的方法是删除
e.preventDefault()代码>行。我假设您的A标记指向#hash_标记,例如:
。下面是我如何使用jQuery激活引导选项卡的示例:
$('#tabs li a').each(function () {
$(this).click(function (e) {
$(this).tab("show");
});
});
问题还不清楚。要手动激活选项卡-只需单击itI我想知道在我单击选项卡后,在DIV部分和url中使用什么代码来显示每个选项卡的ID内容谢谢Alex…你可以聊天吗?我真的被我试图实现这一目标的全部原因所困扰。
$('a').click(function(e){
e.preventDefault();
if(window.location.hash) window.location.hash = '';
window.location.hash = $(e.target).attr('class'); //or id, or other attribute
});
$('#tabs li a').each(function () {
$(this).click(function (e) {
$(this).tab("show");
});
});