我正在使用引导程序作为Web UI。当我单击一个li项目时,它会重定向到新网页,并且活动项目将再次成为第一个项目,如何解决此问题?
<ul id="profileTabs" class="nav nav-list">
<li class="active"><a href="http://localhost/ojr/user/edit/Charles0429" data-toggle="list">Profile</a></li>
<li><a href="http://localhost/ojr/user/edit/Charles0429" data-toggle="list">About Me</a></li>
<li><a href="http://localhost/ojr/user/edit/Charles0429" data-toggle="list">My Match</a></li>
</ul>
您必须使用localstorage或cookie来管理它。
$(function() {
//for bootstrap 3 use 'shown.bs.tab' instead of 'shown' in the next line
$('a[data-toggle="tab"]').on('shown', function (e) {
//save the latest tab; use cookies if you like 'em better:
localStorage.setItem('lastTab', $(e.target).attr('id'));
});
//go to the latest tab, if it exists:
var lastTab = localStorage.getItem('lastTab');
if (lastTab) {
$('#'+lastTab).tab('show');
}
});
代码礼貌如何在重新加载页面后如何使用twitter bootstrap使当前选项卡保持活动状态?
在上面的代码中使用了选项卡,但请尝试用li's
您期望的替换
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句