I. functions:
Write the automatic switch, mouse slide switch, and mouse click switch in a script. You only need to modify the relevant parameters in the html to complete the switching of various effects without re-writing the js script, convenient and practical .........
I. Script Reference
Jquery. js and tabs_jquery.js scripts must be referenced.
<Scripttype = "text/javascript" src = "xxx/jquery-1.7.2.min.js"> </script>
<Scripttype = "text/javascript" src = "xxx/tabs_jquery.js"> </script>
II,HtmlStructure
<Divclass = "tab_atab">
<Ulclass = "tabMenu">
<Liclass = "active"> Tab 1 </li>
<Li> Tab 2 </li>
</Ul>
<Divclass = "tabInner">
<Divclass = "tablistshow"> switch content 1 </div>
<Divclass = "tablisthide"> switch content 2 </div>
</Div>
</Div>
Note:
1. tab, tabMenu, tabInner, and tablist are style structure names. Each tab must be added, but no style is allowed. Note the structure relationship between them: tab is the outermost layer, tabMenu is the switching button layer, tabInner is the content layer to be switched, and tablist is the layer to be displayed and hidden.
2. the tab can be controlled by appending style attributes to the outer layer. For example, <divclass = "tab_atab"> You can append a style to this tab through tab_a.
3. show and hide styles are display and hide attributes. Note that the priority in the style must be greater than that in tablist ). The reference method is as follows:
. Show {display: block ;}
. Hide {display: none ;}
Iii. attribute settings:
<Divclass = "tab_atab" ev = "click" timer = "2000">
<Ulclass = "tabMenu">
<Liclass = "active"> Tab 1 </li>
<Li> Tab 2 </li>
</Ul>
<Divclass = "tabInner">
<Divclass = "tablistshow"> switch content 1 </div>
<Divclass = "tablisthide"> switch content 2 </div>
</Div>
</Div>
The blue part in the html structure description is the property of configurable parameters. The description is as follows:
1. <divclass = "tab">
NOTE: If no parameter is specified, the default switch mode is used. Move the mouse over the Option Button to switch the corresponding content.
2. <divclass = "tab" ev = "click">
Note: The ev = "click" parameter is added, indicating that the corresponding content is switched when you click the Option Button.
3. <divclass = "tab" timer = "2000">
Note: Adding timer = "2000" indicates that automatic switching is performed every 2 seconds.
4. <divclass = "tab" ev = "click" timer = "2000">
Note: The ev and timer parameters are added simultaneously, indicating that the content is automatically switched once every 2 seconds.
5. If you need to display the content of a specific tab by default when loading a webpage, add class = 'active' on the corresponding switch button ', add class = 'show' to the corresponding content display layer, and add class = 'hide 'to other content display layers '.
To display the second tab by default:
<Divclass = "tab_atab" ev = "click" timer = "2000">
<Ulclass = "tabMenu">
<Li> Tab 1 </li>
<Liclass = "active"> Tab 2 </li>
</Ul>
<Divclass = "tabInner">
<Divclass = "tablisthide"> switch content 1 </div>
<Divclass = "tablistshow"> switch content 2 </div>
</Div>
</Div>
4. Others:
For more information about the source code and examples, see the attachment.
This article is from the "shoushou Lanzhou" blog. For more information, contact the author!