jquery implements a picture carousel with left and right arrows and digital focus handwriting code

Source: Internet
Author: User

Before the picture carousel often use the online plug-in, and then want to say that they also have to look carefully, step by step to understand, so on their own research wrote a picture carousel code, I think it is quite simple. If there is improvement, you are welcome to help me point out the common progress.

(PS: Blog Park How to upload code is available for everyone to download that, has not found a place! )

Html:

<Body><Divclass= "Main">    <Divclass= "MySlide">        <ulclass= "Myslidetwo">            <Li><imgsrc= "Img/dn.jpg"/></Li>            <Li> <imgsrc= "Img/ey.jpg"/></Li>            <Li><imgsrc= "Img/fxh.jpg"/></Li>            <Li><imgsrc= "Img/ss.jpg"/></Li>        </ul>        <Pclass= "Arrows">            <aclass= "Pre"><</a>            <aclass= "Next">></a>        </P>        <olclass= "Label">            <Liclass= "Current">1</Li>            <Li>2</Li>            <Li>3</Li>            <Li>4</Li>        </ol>    </Div></Div></Body>

Css:

<style> Body{Background-color:#dddddd; }        * {margin:0px;padding:0px;List-style:None; }a{cursor:Pointer; }. Main{position:relative;width:500px;Height:350px;margin:40px Auto; }. MySlide{float: Left;position:Absolute;Overflow:Hidden;width:500px;Height:350px; }. Myslidetwo{position:Absolute;Overflow:Hidden;width:2000px; }. Myslidetwo img{float: Left;width:500px;Height:350px; }. Label{position:Absolute;Bottom:15px; Left:210px;width:200px; }. Label Li{float: Left;width:20px;Height:20px;Line-height:20px;text-align:Center;Margin-right:5px;Border:1px solid #ddd;font-size:14px;background:#fff;cursor:Pointer; }. Label Li.current{background:#0f0; }. Arrows{position:Absolute; Left:0px;Top:120px;Color:#666;font-size:40px;Font-weight:Bold; }. Arrows a{background:Rgba (0,0,0,0.2);Display:Inline-block;width:30px;Height:70px;text-align:Center;Line-height:70px; }. Arrows A:hover{Color:#fff; }. Arrows. Pre{Margin-right:420px; }</style>

Jquey:

<script>$ (document). Ready (function () {        var_now=0; varOul = $ (". Myslidetwo"); varNUML = $ (". Label Li"); varWID = $ (". MySlide"). EQ (0). width (); //Digital Icon ImplementationNuml.click (function () {            varIndex = $ ( This). index (); $( This). AddClass ("current"). Siblings (). Removeclass (); Oul.animate ({' Left ':-wid * index}, 500); })        //left and RIGHT arrow carousel$ (". Pre"). Click (function () {            if(_now>=1) _now--; Else_now=3;        Ani ();        }); $(". Next"). Click (function () {            if(_now = = Numl.size ()-1) {_now= 0; }            Else_now++;        Ani ();        }); //Animation Functions        functionani () {numl.eq (_now). addclass ("Current"). Siblings (). Removeclass (); Oul.animate ({' Left ':-wid * _now}, 500); }        //The following code if automatic carousel removal is not required        //Auto Animation        var_interval=setinterval (showtime,2000); functionShowTime () {if(_now = = Numl.size ()-1) {_now= 0; }            Else_now++;        Ani (); }        //Stop the Auto animation when the mouse hovers over the screen and leave the recovery$ (". MySlide"). MouseOver (function() {cleartimeout (_interval);        }); $(". MySlide"). Mouseout (function() {_interval=setinterval (showtime,2000);    }); });</script>

jquery implements a picture carousel with left and right arrows and digital focus handwriting code

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.