支持收缩和展开
缺省情况下,标签页是展开的,可以通过设置collapsible为true使得标签页支持收缩和展开。
Ajax支持
jQuery 的标签页也支持通过Ajax方法来加载页面,这是通过设置href属性来实现,href指向其它页面,这是jQuery通过Ajax方法读取指定页面,如果加载时间过长,则页面显示Loading(加载中),如果无法加载,也可以通过配置beforeLoad 设置错误信息。
4 |
beforeLoad: function( event, ui ) { |
5 |
ui.jqXHR.error(function() { |
7 |
"Couldn't load this tab. We'll try to fix this as soon as possible. " + |
8 |
"If this wouldn't be a demo." ); |
19 |
< li >< a href = "#tabs-1" >Preloaded</ a ></ li > |
20 |
< li >< a href = "ajax/content1.html" >Tab 1</ a ></ li > |
21 |
< li >< a href = "ajax/content2.html" >Tab 2</ a ></ li > |
22 |
< li >< a href = "ajax/content3-slow.php" >Tab 3 (slow)</ a ></ li > |
23 |
< li >< a href = "ajax/content4-broken.php" >Tab 4 (broken)</ a ></ li > |
26 |
< p >Proin elit arcu, rutrum commod</ p > |
鼠标移动自动激活页面
可以通过设置 event:mouseover 来实现,这样当鼠标移动到某个页面,该页面则自动展开。
在底部和左边显示标签头
通过CSS和一些JavaScript可以把标签页的标题显示在底部或是左边
5 |
< title >jQuery UI Demos</ title > |
6 |
< link rel = "stylesheet" href = "themes/trontastic/jquery-ui.css" /> |
7 |
< script src = "scripts/jquery-1.9.1.js" ></ script > |
8 |
< script src = "scripts/jquery-ui-1.10.1.custom.js" ></ script > |
14 |
$(".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *") |
15 |
.removeClass("ui-corner-all ui-corner-top") |
16 |
.addClass("ui-corner-bottom"); |
18 |
// move the nav to the bottom |
19 |
$(".tabs-bottom .ui-tabs-nav").appendTo(".tabs-bottom"); |
23 |
/* force a height so the tabs don't jump as content height changes */ |
29 |
.tabs-bottom .ui-tabs-nav { |
31 |
padding: 0 .2em .2em .2em; |
34 |
.tabs-bottom .ui-tabs-nav li { |
42 |
.tabs-bottom .ui-tabs-nav li.ui-tabs-active { |
50 |
< div id = "tabs" class = "tabs-bottom" > |
52 |
< li >< a href = "#tabs-1" >Nunc tincidunt</ a ></ li > |
53 |
< li >< a href = "#tabs-2" >Proin dolor</ a ></ li > |
54 |
< li >< a href = "#tabs-3" >Aenean lacinia</ a ></ li > |
57 |
< p >Proin elit arcu, rutrum commodo, vehicula tempus, </ p > |
60 |
< p >Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, </ p > |
63 |
< p >Mauris eleifend est et turpis. Duis id erat. </ p > |
64 |
< p >Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, </ p > |
5 |
< title >jQuery UI Demos</ title > |
6 |
< link rel = "stylesheet" href = "themes/trontastic/jquery-ui.css" /> |
7 |
< script src = "scripts/jquery-1.9.1.js" ></ script > |
8 |
< script src = "scripts/jquery-ui-1.10.1.custom.js" ></ script > |
11 |
$("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix"); |
12 |
$("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left"); |
20 |
.ui-tabs-vertical .ui-tabs-nav { |
21 |
padding: .2em .1em .2em .2em; |
26 |
.ui-tabs-vertical .ui-tabs-nav li { |
29 |
border-bottom-width: 1px !important; |
30 |
border-right-width: 0 !important; |
31 |
margin: 0 -1px .2em 0; |
34 |
.ui-tabs-vertical .ui-tabs-nav li a { |
38 |
.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { |
41 |
border-right-width: 1px; |
42 |
border-right-width: 1px; |
45 |
.ui-tabs-vertical .ui-tabs-panel { |
56 |
< li >< a href = "#tabs-1" >Nunc tincidunt</ a ></ li > |
57 |
< li >< a href = "#tabs-2" >Proin dolor</ a ></ li > |
58 |
< li >< a href = "#tabs-3" >Aenean lacinia</ a ></ li > |
61 |
< p >Proin elit arcu, rutrum commodo, vehicula tempus, </ p > |
64 |
< p >Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, </ p > |
67 |
< p >Mauris eleifend est et turpis. Duis id erat. </ p > |
68 |
< p >Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, </ p > |