JavaScript picture Carousel, extrapolate

Source: Internet
Author: User

Picture Carousel, in some shopping sites to use the list, the following is a brief introduction of a carousel implementation.

<!doctype html>. body{width:524px; Border:solid 1px #666; Margin-Left:auto; Margin-Right:auto; }. bg{Background-color: #E0E0E0;        height:20px; Border-top:solid 1px #B4B4B4; }. number{Font-size:14px; Font-Weight:bold;        Color: #FFF; Background-color: #9E2E07;        Display:block;        border:1px solid #FFF;        width:18px;        height:18px; Text-Align:center; Margin-left:10px;        Cursor:pointer; float: Left;        }. numberover{color: #8C2806; Font-size:14px;        width:280px; Background-color: #FFF; Text-Align:center; float: Left;        Display:block; Margin-left:10px; }.main{Width:95%; Margin-Left:auto; Margin-Right:auto; }. left_indent{padding-left:20px;        }. red{color: #F00; }      </style> class= "Body" > <divclass= "BG" > <divclass= "Number" id= "fig_1" onclick= "show (1);" >1</div> <divclass= "Number" id= "Fig_2" onclick= "show (2);" >2</div> <divclass= "Number" id= "Fig_3" onclick= "show (3);" >3</div> <divclass= "Number" id= "Fig_4" onclick= "show (4);" >4</div> </div> </div> </body> <script type= "Text/javascript" >//JavaScript Document//Defining global Variablesvar title=NewArray (); title[0]= "1. Shop celebrate the first wave of three crazy day! "; title[1]= "2. Ten years shop the average Price field 39/99/169 special session! "; title[2]= "3. Full 69 percent discount for the value of the low price! "; title[3]= "4. Shop celebrates a huge amount of books 69 percent ceiling"; var nowframe= 1;//First picture shownvar maxframe = 4;//altogether five picturesfunction Show (d1) {if(number (D1)) {cleartimeout (Thetimer); //clears the timer when the touch button is touchedNOWFRAME=D1;//set the current display picture        }     for(Var i=1;i< (maxframe+1); i++){        if(i==nowframe) {document.getElementById ("Rotator"). src = "ad-0" +i+ ". jpg";//Show current picturedocument.getElementById ("Fig_" +i). Innerhtml=title[i-1];//Displays the title of the current picturedocument.getElementById ("Fig_" +i). Classname= "Numberover";//set CSS style for the current title         }         Else{document.getElementById ("Fig_" +i). innerhtml=i; document.getElementById ("Fig_" +i). Classname= "Number"; }    }    if(Nowframe = = maxframe) {//set the next displayed pictureNowframe = 1; }    Else{nowframe++; }}var Thetimer=setinterval (' Show () ', 3000);//set a timer to display the next pictureWindow.onload=show;//run function Show () when page loads</script>

JavaScript picture Carousel, extrapolate

Related Article

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.