Carousel Figure project summary

window.onload=function () {
 
    var items = document.getElementsByClassName ( " Item " );                       case obtained images, a collating
     var alist = document.getElementById ( " alist " ) .getElementsByTagName ( " A " ); dots obtained at this time, a button to switch picture 
var lbtn = document.getElementById ( " lbtn " ); to obtain the left button var RBTN = document.getElementById ( " RBTN " ); to obtain the right button var index = 0 ; index declare a variable, as an index, the default is 0 var clearactive=function () { for (var m=0;m<items.length;m++){ items [m] .className = " Item " ; this case the modified class values for all images "item", full restoration of the original pattern } for (var m=0;m<alist.length;m++){ alist [m] .className = " Ali " At this time, all of the dots is to modify the value of class "ali", to restore the original pattern

}};
 
 

goindex function = var () {
clearactive ();
items [index] = .className "Active Item"; call the above clearactive () function, and while the class value and the dot image increases and activea avtive
    alist [index] = .className "Ali activea"             
};

var gonext = function () {gonext declare a method, and determines the value of the index, then the index value of between 4 and locked in 0, if the index is equal to 5,
if (index <4) {the index = 0, and jump to the first image at this time 0.
++ index;
} the else {
index = 0
}
goindex ()
};

var Goup = function () {
IF (index == 0) {index determination, if the index = 0, then execute index = 4, if the index is not equal to 0, the index continues to decrement
index =. 4;
} the else {
index the
}
goindex ()
};


rbtn.onclick = function () {right button to execute gonext () method
gonext ();

};

lbtn.onclick = function () {Goup left button to execute () method
Goup ()
};


the setInterval (function () {this was added at a timer, set to two parameters, the first parameter is anonymous function, the second time, and calls gonext () method, performed once every 6 seconds
gonext ()
}, 6000);
 

 

Guess you like

Origin www.cnblogs.com/dumenglong/p/11027750.html