Example:
<div class= "tab" > <div class= "Tab_menu" > <ul> <li class= "selected" > Current events </li > <li> Sports </li> <li> Entertainment </li> </ul> </div> <div class = "Tab_box" > <div> events </div> <div class= "Hide" > Sports </div> <div class= "Hide "> Entertainment </div> </div></div>
Requirements: Bind the order-click event for the <li> element, highlight the currently clicked <li> element, and then remove the highlighting of the other sibling <li> elements while switching the tab contents.
The code is as follows:
var $div _li = $ ("Div.table_menu ul Li"), $div _li.click (Functijon () { $ (this). AddClass ("selected")//Current <li> Highlight . Siblings (). Removeclass ("selected");//Other peers <li> remove highlight var index = $div _li.index (this);//Get current click <li > Index in all <li> $ ("div_tab_box>div")//Select child nodes . EQ (index). Show ();//Display the current <li> corresponding tab content . Siblings (). Hide ()//hides other peers <li> corresponding tab content});
jquery App Action---page tab (tabs)