In the development of the Web site will often use the TAB function, in order to save the time to write code, encapsulating the tab plug-in, easy to invoke.
Create a TAB component
How to use: HTML structure
<div id= "tabs" >
<ul>
<li><a href= "#tabs-1" >tab-1</a></li>
<li ><a href= "#tabs-2" >tab-2</a></li>
<li><a href= "#tabs-3" >tab-3</a>< /li>
</ul>
<div id= "tabs-1" >tabs-1-panel</div>
<div id= "Tabs-2" > tabs-2-panel</div>
<div id= "tabs-3" >tabs-3-panel</div>
</div>
JS Call
Related parameter Description:
Initialization parameters
Parameter Default value parameter description
Active NULL sets the index of the selected tab, with a default value of NULL, such as setting the first tab to 0
Event Click Tab switch Events, default to click events, you can set mouseover
Add Tab parameters
Parameter Default value parameter description
Text displayed by the title Empty tab, default to NULL
href Empty tab link, if static data is filled in the corresponding string (#str), the remote data is the corresponding URL
Content blank tab is static data, dynamic data is not required to fill in
ICONCLS true tab Close button, default to display True, False if not displayed
Demo:
Example 1: Static data:
<div id= "tabs" >
<ul>
<li><a href= "#tabs-1" >tab-1</a></li>
<li ><a href= "#tabs-2" >tab-2</a></li>
<li><a href= "#tabs-3" >tab-3</a>< /li>
</ul>
<div id= "tabs-1" >tabs-1-panel</div>
<div id= "Tabs-2" > tabs-2-panel</div>
<div id= "tabs-3" >tabs-3-panel</div>
</div>
JS Call:
Example 2: A panel is dynamically created by loading the page with remote data.
<div id= "tabs" >
<ul>
<li><a href= "#tabs-1" >tab-1</a></li>
<li ><a href= "index.jsp" >tab-2</a></li>
<li><a href= "index.html" >tab-3</a ></li>
</ul>
<div id= "tabs-1" >tabs-1-panel</div>
</div>
JS Call:
Example 3: Incoming parameter, setting tab toggle event to MouseOver
<div id= "tabs" >
<ul>
<li><a href= "#tabs-1" >tab-1</a></li>
<li><a href= "index.jsp" >tab-2</a></li>
<li><a href= "index.html" >tab-3 </a></li>
</ul>
<div id= "tabs-1" >tabs-1-panel</div>
</div>
JS Call:
$ (' #tabs '). Tabs ({event: ' mouseover '});
Example 4: Add Tab:
<input type= "button" value= "Add Tab" onclick= "AddTab ()" >
<div id= "tabs" >
<ul>
<li ><a href= "#tabs-1" >tab-1</a></li>
<li><a href= "index.jsp" >tab-2</a> </li>
<li><a href= "index.html" >tab-3</a></li>
</ul>
<div id= " Tabs-1 ">tabs-1-panel</div>
</div>
JS Call:
$ (' #tabs '). tabs ();
var tabcount =4;
function AddTab () {
tab.tabs (' Add ', {
title: ' tab-' +tabcount+ ',
href: ' #tab-' +tabcount+ ',
Content: ' Tab----' +tabcount+ ',
iconcls:true
});
tabcount++;
}
Summarize:
Called with different IDs, you can create a different tab structure, with the styles defining different styles by ID.
Little brother. Welcome to the Great God advice ....
Demo Download Address: Myui-tabs
The above mentioned is the entire content of this article, I hope you can enjoy.