为另一个 div 创建一组新的工作选项卡和窗格
这是我的 css:
ul.tabs {
list-style:none;
margin: 0!important;
padding:0;
border-bottom:0px solid #666;
height:30px;
}
/* single tab */
ul.tabs li {
float:left;
text-indent:0;
padding:0;
margin:0 !important;
list-style-image:none !important;
}
/* link inside the tab. uses a background image */
ul.tabs a {
background-color: #000000;
font-size:12px;
display:block;
height: 30px;
line-height:30px;
width: 134px;
text-align:center;
text-decoration:none;
color:#FFFFFF;
padding:0px;
margin:0px;
position:relative;
background-image: url();
background-repeat: no-repeat;
background-position: -420px 0;
font-family: arial;
font-weight: bold;
text-transform: uppercase;
}
ul.tabs a:active {
outline:none;
}
/* when mouse enters the tab move the background image */
ul.tabs a:hover {
background-position: -420px -31px;
color:#fff;
}
/* active tab uses a class name "current".
its highlight is also done by moving the background image. */
ul.tabs a.current, ul.tabs a.current:hover, ul.tabs li.current a {
background-position: -420px -62px;
cursor:default !important;
color:#000 !important;
}
/* initially all panes are hidden */
.panes .pane {
display:none;
}
.panes div {
display:none;
padding:15px 10px;
border:medium solid #000000;
height:150px;
font-size:14px;
background-color: #0099FF;
}
这是我的 HTML:
<div class="panes">
<div>working pane 1</div>
<div>working pane 2</div>
<div>working pane 3</div>
</div>
<ul class="tabs">
<li><a href="#">Working Tab1</a></li>
<li><a href="#">Working Tab2</a></li>
<li><a href="#">Working Tab3</a></li>
</ul>
<p>
<div class="Next Set of Tabs I want to work">
<ul class="tabs">
<li><a href="#">tab 1</a></li>
<li><a href="#">tab 2</a></li>
</ul>
<div class="Next Set of Panes I want to work">
<div>member pane 1</div>
<div>member pane 2</div>
<div>member pane 3</div>
</div>
</div
这是我的 javascript:
// perform JavaScript after the document is scriptable.
$(function() {
// setup ul.tabs to work as tabs for each div directly under div.panes
$("ul.tabs").tabs("div.panes > div");
});
</script>
如何创建可在文档中其他位置使用的第二组和第三组选项卡和窗格?我尝试过自己的一些编辑,但惨遭失败。
另外,我必须对我的 javascript 进行哪些更改才能使其适用于除当前选项卡和窗格之外的添加选项卡和窗格?
请用代码中的示例回复。提前致谢。
This is my css:
ul.tabs {
list-style:none;
margin: 0!important;
padding:0;
border-bottom:0px solid #666;
height:30px;
}
/* single tab */
ul.tabs li {
float:left;
text-indent:0;
padding:0;
margin:0 !important;
list-style-image:none !important;
}
/* link inside the tab. uses a background image */
ul.tabs a {
background-color: #000000;
font-size:12px;
display:block;
height: 30px;
line-height:30px;
width: 134px;
text-align:center;
text-decoration:none;
color:#FFFFFF;
padding:0px;
margin:0px;
position:relative;
background-image: url();
background-repeat: no-repeat;
background-position: -420px 0;
font-family: arial;
font-weight: bold;
text-transform: uppercase;
}
ul.tabs a:active {
outline:none;
}
/* when mouse enters the tab move the background image */
ul.tabs a:hover {
background-position: -420px -31px;
color:#fff;
}
/* active tab uses a class name "current".
its highlight is also done by moving the background image. */
ul.tabs a.current, ul.tabs a.current:hover, ul.tabs li.current a {
background-position: -420px -62px;
cursor:default !important;
color:#000 !important;
}
/* initially all panes are hidden */
.panes .pane {
display:none;
}
.panes div {
display:none;
padding:15px 10px;
border:medium solid #000000;
height:150px;
font-size:14px;
background-color: #0099FF;
}
This is my HTML:
<div class="panes">
<div>working pane 1</div>
<div>working pane 2</div>
<div>working pane 3</div>
</div>
<ul class="tabs">
<li><a href="#">Working Tab1</a></li>
<li><a href="#">Working Tab2</a></li>
<li><a href="#">Working Tab3</a></li>
</ul>
<p>
<div class="Next Set of Tabs I want to work">
<ul class="tabs">
<li><a href="#">tab 1</a></li>
<li><a href="#">tab 2</a></li>
</ul>
<div class="Next Set of Panes I want to work">
<div>member pane 1</div>
<div>member pane 2</div>
<div>member pane 3</div>
</div>
</div
and this is my javascript:
// perform JavaScript after the document is scriptable.
$(function() {
// setup ul.tabs to work as tabs for each div directly under div.panes
$("ul.tabs").tabs("div.panes > div");
});
</script>
How do I create a 2nd and 3rd set of tabs and panes that I can use elsewhere in my document? Ive tried some edits of my own but I failed miserably.
Also, what changes do I have to make to my javascript so that it will work for the added tabs and panes in addition to the current one?
Please reply with example in code. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有提供有关您正在使用哪个 jQuery 插件的任何详细信息。但是,如果您使用 jQuery 工具“选项卡”插件,那么我建议您使用 .each() 循环运行选项卡插件,并获取具有唯一引用的窗格。
抱歉,如果这很模糊;但我们可以提供有关该插件的更多详细信息。
You've not provided any details on which jQuery plugin you're using. However, if you're using the jQuery Tools "Tabs" plugin, then I suggest you run through the tabs plugin with an .each() loop, and get the panes with unique references.
Sorry if this is quite vague; but we could do with more details on the plugin.