Auto Toggle Function Tab TAB effect

Source: Internet
Author: User

First take a look at the effect of the picture, I do not beautify just the example function of the following figure.

Implementation code, jquery file I directly use the official address, you can download.

The code is as follows Copy Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Universal tab-has automatic rotation function </title>
<script src= "Http://code.jquery.com/jquery-1.6.4.min.js" type= "Text/javascript" ></script>
<style type= "Text/css" >
<!--
* {
padding:0;
margin:0;
List-style:none;
}
. cur {
Color: #000;
Background-color: #FFF;
}
. Red {
font-size:20px;
Font-weight:bolder;
}
#lxfTab-click {
-moz-border-radius:5px;
Background-color: #069;
width:600px;
Overflow:hidden;
padding:2px;
margin-top:20px;
Margin-left:auto;
Margin-right:auto;
}
#lxfTab-click. Title {
Color: #FFF;
}
#lxfTab-click. title Li {
Float:left;
padding:1px;
Cursor:pointer;
width:40px;
margin:8px 0 8px 8px;
border:1px solid #FFF;
-moz-border-radius:5px;
Text-align:center;
}
#lxfTab-click. Content {
width:600px;
Float:left;
}
#lxfTab-click. Content Li {
Word-wrap:break-word;
Background-color: #FFF;
padding:6px;
-moz-border-radius:5px;
width:572px;
margin-top:0px;
margin-right:8px;
margin-bottom:8px;
margin-left:8px;
}
-->
</style>
<script>
$ (function () {
$ ("#lxfTab-click. Title Li:first") addclass ("cur");
$ ("#lxfTab-click. Content Li:not (: a)"). Hide ();
$ ("#lxfTab-click. Title Li"). Click (function () {
var index = $ ("#lxfTab-click. Title li"). Index ($ (this));
$ ("#lxfTab-click. Title Li"). Removeclass ("cur");
$ (this). AddClass ("cur");
$ ("#lxfTab-click. Content li"). Hide (). EQ (index). FadeIn ("fast");
$ (". Now"). Text (index + 1);
});
/* Automatic Rotation * *
var i =-1;
Set Start position
var speed = 2000;
Set rotation speed
var n = $ ("#lxfTab-click. Title Li"). Length-1;
function Autoroll () {
if (i >= N) {
i =-1;
}
i++;
$ ("#lxfTab-click. Title Li"). Removeclass ("cur"). EQ (i) addclass ("cur");
$ ("#lxfTab-click. Content li"). Hide (). EQ (i). FadeIn ("fast");
Timer = settimeout (autoroll, speed);
};
/* Mouse hover stop automatic rotation *
function Stoproll () {
$ ("#lxfTab-click li"). Hover (function () {
Cleartimeout (timer);
i = $ (this). Prevall (). length;
}, function () {
Timer = settimeout (autoroll, speed);
});
};
Autoroll ();
To perform an automatic rotation function
Stoproll ();
Start hover function
});
</script>
<body>
<div id= "Lxftab-click" >
<ul class= "title" >
<li>
1
</li>
<li>
2
</li>
<li>
3
</li>
<li>
4
</li>
<li>
5
</li>
</ul>
<div class= "Lrbutton" >
<ul>
<li></li><li></li><li></li>
</ul>
</div>
<ul class= "Content" >
<li>
1
</li>
<li>
2
</li>
<li>
3
</li>
<li>
4
</li>
<li>
5
</li>
</ul>
</div>
</body>


All right, copy this code and you can use it.

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.