jquery tab Toggle

Source: Internet
Author: User

Html

<! DOCTYPE html>

Css

* {padding:0; margin:0;} body {font-size:12px; padding:100px;} UL {List-style-type:none;}. Box ul {height:30px; line-height:30px;}. Box ul li {float:left; padding:0 10px; position:relative; Cursor:pointer; border:1px solid #000; margin-right:5px; Border-bottom:none;}. Box ul li.two {background: #eee;}. content {width:325px; border:1px solid #000; padding:10px; height:100px;} * HTML. Content {margin-top:-1px;}//Browser compatible Ie6.box ul li.one {background-color:black;color:white;}

Js

$ (document). Ready (function () {$ ('. CT:GT (0) '). Hide ();   The hidden GT with content greater than 0    (0) is greater than 0var BT = $ ('. Box ul Li '); Bt.hover (function () {$ (this). addclass ('). Siblings (). Removeclass ( ' both ');   The current element adds a class sibling element to remove class});       Bt.click (function () {$ (this). addclass (' one '). Siblings (). Removeclass ();//link the index of the title to the content index var content_index = Bt.index (this);
Content switch $ ('. Ct '). EQ (Bt.index (this)). Show (). siblings (). Hide ();});

Effect:

09:52:18 2017-09-24

jquery tab Toggle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.