JQuery idTabs - 哈希问题
我有一个带有 3 个选项卡的简单 html 页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>idTabs</title>
<script type="text/javascript" src="http://www.sunsean.com/idTabs/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="http://www.sunsean.com/idTabs/jquery.idTabs.min.js"></script>
</head><body style="background-color:White; color:Black">
<style type="text/css">
/* Jquery Tabbed Panels */
div.idTabs
{
float:left;
margin-top:30px;
}
.idTabs a
{
display: block;
padding: 10px;
color: #333;
background: #DDF1FF;
font: 11px Verdana, Geneva, sans-serif;
text-decoration: none;
border: none;
}
.idTabs a.selected
{
background: #FFF;
color: #333;
border-bottom: solid 1px #FFF;
z-index: 120;
}
</style>
<div class="vi_wrapper">
<div class="idTabs">
<ul style=" padding: 0px; position: relative; z-index: 100;">
<li style="display: block; list-style: none; float: left; background: #CCC; padding: 1px 1px 0px 1px; margin-right:4px;">
<a class="selected" href="#Tab1" name="Tab1">Tab1</a>
</li>
<li style="display: block; list-style: none; float: left; background: #CCC; padding: 1px 1px 0px 1px; margin-right:4px;">
<a href="#Tab2" name="Tab2">Tab2</a>
</li>
<li style="display: block; list-style: none; float: left; background: #CCC; padding: 1px 1px 0px 1px; margin-right:4px;">
<a href="#Tab3" name="Tab3">Tab3</a>
</li>
</ul>
<div class="items">
<div id="Tab1">
<div style="float:left">
Tab1
<br />
here is hash, and when you click on it - no tab:
<br />
<a href="#SomeHashTab1">Some Hash 1</a>
</div>
</div>
<div id="Tab2">
<div style="float:left">
Tab2
<br />
here is hash, and when you click on it - no tab:
<br />
<a href="#SomeHashTab2">Some Hash 2</a>
</div>
</div>
<div id="Tab3">
<div style="float:left">
Tab3
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(".idTabs").idTabs(true, location.hash);
</script>
</div>
</body></html>
因此,每个选项卡都通过链接中的哈希值打开(#Tab1、#Tab2、#Tab3),但是如果我将其他带有哈希值的链接添加到选项卡内容中,它会打开一个空选项卡。
如何跳过对非选项卡哈希的所有哈希的点击? 多谢!
I have simple html page with 3 tabs:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>idTabs</title>
<script type="text/javascript" src="http://www.sunsean.com/idTabs/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="http://www.sunsean.com/idTabs/jquery.idTabs.min.js"></script>
</head><body style="background-color:White; color:Black">
<style type="text/css">
/* Jquery Tabbed Panels */
div.idTabs
{
float:left;
margin-top:30px;
}
.idTabs a
{
display: block;
padding: 10px;
color: #333;
background: #DDF1FF;
font: 11px Verdana, Geneva, sans-serif;
text-decoration: none;
border: none;
}
.idTabs a.selected
{
background: #FFF;
color: #333;
border-bottom: solid 1px #FFF;
z-index: 120;
}
</style>
<div class="vi_wrapper">
<div class="idTabs">
<ul style=" padding: 0px; position: relative; z-index: 100;">
<li style="display: block; list-style: none; float: left; background: #CCC; padding: 1px 1px 0px 1px; margin-right:4px;">
<a class="selected" href="#Tab1" name="Tab1">Tab1</a>
</li>
<li style="display: block; list-style: none; float: left; background: #CCC; padding: 1px 1px 0px 1px; margin-right:4px;">
<a href="#Tab2" name="Tab2">Tab2</a>
</li>
<li style="display: block; list-style: none; float: left; background: #CCC; padding: 1px 1px 0px 1px; margin-right:4px;">
<a href="#Tab3" name="Tab3">Tab3</a>
</li>
</ul>
<div class="items">
<div id="Tab1">
<div style="float:left">
Tab1
<br />
here is hash, and when you click on it - no tab:
<br />
<a href="#SomeHashTab1">Some Hash 1</a>
</div>
</div>
<div id="Tab2">
<div style="float:left">
Tab2
<br />
here is hash, and when you click on it - no tab:
<br />
<a href="#SomeHashTab2">Some Hash 2</a>
</div>
</div>
<div id="Tab3">
<div style="float:left">
Tab3
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(".idTabs").idTabs(true, location.hash);
</script>
</div>
</body></html>
So, each tab opens by hash in the link (#Tab1, #Tab2, #Tab3), but if I add some other link with hash into tab content, it opens me an empty tab.
How can I skip the clicks on all hashes that are not of tab hash?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将
items
DIV 移至idTabs
DIV 外部即可。看来该插件将选项卡效果绑定到所有包含哈希的链接上。编辑:
Just move the
items
DIV outside theidTabs
DIV. It seems that the plugin binds the tabs effect on all the links that contains hashes.EDIT:
编辑:不是
'#'+location.hash
,因为location.hash
已经包含'#'
。EDIT: Not
'#'+location.hash
, becauselocation.hash
already includes a'#'
.