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.