Jquery achieves TAB-like image switching

Source: Internet
Author: User

The effect is as follows:

Code

The code is as follows: Copy code
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> jquery Image switching for vertical emission of the index button </title>
<Style type = "text/css">
* {Margin: 0; padding: 0; list-style-type: none ;}
A, img {border: 0 ;}
Body {font: 12px "Helvetica Neue", Helvetica, STheiti,,, Arial, Tahoma, sans-serif, serif}
Body {background: # f6f6f6}
. Fl {float: left}
A {text-decoration: none}
. Clearfix: after {content: "."; display: block; height: 0; clear: both; visibility: hidden}
. Clearfix {display: inline-block}
* Html. clearfix {height: 1%}
. Clearfix {display: block}
/* M-banner */
. M-banner {padding: 10px 10px 0; height: 239px; border: 1px solid # dedede; width: 755px; margin: 20px auto ;}
. Mb-news {width: 270px; padding: 0 15px; line-height: 1.8}
. Mb-news h4 {word-break: break-all; word-wrap: break-word}
. Mb-news h4 a {font-size: 18px; color: #8c3608; line-height: 1.6; word-break: break-all; word-wrap: break-word}
. Mb-news p {font-size: 14px; color: #444; margin-top: 15px; overflow: hidden}
. Mb-news h4 a: hover {text-decoration: underline}
. Mb-img {width: 455px; height: 239px}
. Mb-inav {width: 10px; margin-right: 1px}
. Mb-inav li {width: 10px; height: 79px; margin-bottom: 1px}
. Mb-inav li a {display: block; width: 10px; height: 79px; background: # bdbdbd}
. Mb-inav li a. cur {background: #671900}
. Mb-ibox {width: 444px; height: 239px; position: relative; overflow: hidden}
. Mb-ibox a {display: block; width: 444px; height: 239px; overflow: hidden; position: absolute; top: 0; left: 0; z-index: 10; display: none}
</Style>
<Script src = "/ajaxjs/jquery-1.9.1.min.js" type = "text/javascript"> </script>
<Script type = "text/javascript">
$ (Function (){
// Image carousel
BannerRotate. bannerInit ();
});
Var bannerRotate = {
_ Time: 3000,
_ Fade: 200,
_ I: 0,
_ Interval: null,
_ NavId: "# mb-inav ",
_ NavBox: "# mb-ibox ",
_ NavTxt: "# mb-itxt ",
BannerShow: function (){
$ (This. _ navId). find ("li a"). removeClass ("cur ");
$ (This. _ navId ). find ("li: eq (" + this. _ I + ")"). find (""). addClass ("cur ");
  
$ (This. _ navBox). find ("a"). fadeOut (this. _ fade );
$ (This. _ navBox). find ("a: eq (" + this. _ I + ")"). fadeIn (this. _ fade );
  
$ (This. _ navTxt). find ("div"). hide ();
$ (This. _ navTxt). find ("div: eq (" + this. _ I + ")"). fadeIn (this. _ fade );
},
BannerStart: function (){
Var _ this = this;
_ This. _ interval = setInterval (function (){
If (_ this. _ I> = 2 ){
_ This. _ I = 0;
   }
Else {
_ This. _ I ++;
   }
_ This. bannerShow ();
}, _ This. _ time );
},
BannerInit: function (){
Var _ this = this;
_ This. bannerStart ();
$ (_ This. _ navId). find ("li a"). bind ("mouseover", function (){
ClearInterval (_ this. _ interval );
_ This. _ I = $ (this). parent (). index ();
_ This. bannerShow ();
_ This. bannerStart ();
});
 }
};
</Script>
</Head>
<Body>
<Div class = "m-banner">
<Div id = "mb-itxt" class = "mb-news fl">
<Div style = "display: block;">
<H4> <a href = "/"> switch the image tab </a> <P> try switching the image with 12345 numbers, switching the image with a thumbnail, and switching the image with the tutorial and source code. </p>
</Div>
<Div style = "display: none;">
<H4> <a href = "/"> beautiful scenery </a> <P> content222. .. </p>
</Div>
<Div style = "display: none;">
<H4> <a href = "/"> fierce fields </a> <P> content333. .. </p>
</Div>
</Div>
<Div class = "mb-img fl clearfix">
<Ul id = "mb-inav" class = "mb-inav fl">
<Li> <a class = "cur"> </a> </li>
<Li> <a> </li>
<Li> <a> </li>
</Ul>
<Div id = "mb-ibox" class = "mb-ibox fl">
<A href = "/" style = "display: block; "> </a>
<A href = "/"> </>
<A href = "/"> </>
</Div>
</Div>
</Div>
<Div style = "text-align: center; clear: both">
</Div>
</Body>
</Html>

Tip: There is a jquery plug-in file. You can download the latest jquery package online.

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.