JS native Belt Small white point carousel Map

Source: Internet
Author: User

We just talked about JS native Carousel, now add a little polka dot that you can walk with!

CSS code:

*{margin:0px;padding:0px;} Ul{width:2500px;height:300px;position:absolute;} Li{float:left;list-style:none;} img{width:500px;height:300px;} div{width:500px;height:300px;margin:50px Auto;position:relative;overflow:hidden;} /* ul*/of small white point #round_ul {width:300px;height:30px;/*background:yellow;*/position:relative;margin:250px auto;} #round_ul li{width:20px;height:20px;border-radius:50%;background: #2196f3; margin-left:50px;cursor:pointer;}

HTML code:

<div><ul><li></li><li>< /li><li></li><li></li><li ></li></ul><ul id= "Round_ul" ><li></li><li> </li><li></li><li></li></ul>

JS section:

<script type= "Text/javascript" >//execute code After page load is completeWindow.onload =function(){        //Get UL        varImgul = document.getElementsByTagName ("ul") [0]; varGroundul = document.getElementById ("Round_ul"); //Change the first small white point to a child node of the Red Children node (not a blank node)Groundul.children[0].style.backgroundcolor = "Red"; varsid,x = 0; //Start Timer function        functionfn () {sId= SetInterval (abc,10); }        functionABC () {//revise the UL coordinates every 10 seconds, modify 1pxImgUl.style.left = x--+ "px"; //If a picture goes completely into the Div            if(x% 500 = = 0){                //invoke modify small white point function                if(x = =-2000) {x= 0; ImgUl.style.left= 0 + "px"; } Changli (Math.Abs (x/500));//Call to modify the small white point method Clearinterval (sId);//Tentative TimerSetTimeout (fn,1000);//every 100 milliseconds in the secondary start timer}} fn ();//Modify the small white point method        functionChangli (num) {//traversing small white point groups             for(varx = 0;x<4;x++){                //change all the dots to blueGroundul.children[x].style.backgroundcolor = "#2196f3"; }            //change the corresponding small white point to redGroundul.children[num].style.backgroundcolor = "Red"; }    }</script>

That's it!! Do you understand??

JS native Belt Small white point carousel Map

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.