jquery +css instance tab option sliding door effect

Source: Internet
Author: User

You can save the following code as JS. File
Defining Global Variables
var timeout;
$ (document). Ready (function () {
Find all the LI tags
$ ("Li"). each (function (index) {

$ (this). MouseOver (function () {
Sliding doors have to set a delay time to avoid the user crazy mobile mouse, causing the server to crash, this is very important
Timeout =settimeout (function () {
$ ("Div.divarea"). Removeclass ("Divarea");
$ ("Li.listli"). Removeclass ("Listli");
$ ("div"). EQ (index). addclass ("Divarea"); Another type of writing is: $ (div:eq (index)). addclass ("Divarea");
$ ("Div:eq (" +index+ ")"). AddClass ("Divarea");
$ ("li"). EQ (index). addclass ("Listli");
},
320);
$ (this). Mouseout (function () {
Cleartimeout (timeout);
});
});
});
});

Front HTML code


<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>tab </TITLE>
<link rel= "stylesheet" type= "text/css Tutorial" href= "Css/tab.css" >
<script type= "Text/javascript tutorial" src= "Js/jquery-1.4.2.js" ></script>
<script type= "Text/javascript" src= "Js/tab.js" ></script>
</HEAD>

<BODY>
<ul id= "Ularea" >
<li class= "Listli" > Label 1</li>
<li > Label 2</li>
<li > Label 3</li>
</ul>
<div class= "Divarea" > Content 1</div>
<div> content 2</div>
<div> content 3</div>
</BODY>
</HTML>

Save this code as CSS code


UL, Li {margin:0px;
padding:0px;
List-style:none;
}
Li {float:left;
Background-color: #66CC00;
margin-right:2px; This is to set the spacing between the labels
padding:5px;
border:1px solid white;
height:20px;
Color:white;

}
. listli {background-color: #663333;
border:1px solid #663333;

}
div {clear:left;
width:300px;
height:100px;
Background-color: #663333;
border-top:0px;
Color:white;
Display:none;
}

. Divarea {Display:block}

Related Article

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.