Home  >  Article  >  Web Front-end  >  Javascript example code to implement scrolling picture news_javascript skills

Javascript example code to implement scrolling picture news_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:12:251038browse

The following code is used to implement picture news

Copy the code The code is as follows:

var index = 0;
var Timer = null;

function initGallery(){
for(var i=0; i< 4; i ){
document.getElementById("fPic" i).style.display = "none";
document .getElementById("fTitl" i).style.display = "none";
document.getElementById("fNum" i).style.className = "numOff";
}
startChange();
setTimer();
}

function startChange(){
index = index % 4;

changePic(index);
changeTitl(index);
changeNum(index);

index ;
}

function changePic(index){
for(var i=0; i<4;i ){
document.getElementById("fPic" i).style.display = "none";
}
document.getElementById("fPic" index).style.display = "block";
}

function changeTitl(index){
for(var i=0; i<4; i ){
document.getElementById("fTitl" i).style.display = "none";
}
document.getElementById("fTitl" index).style.display = "block";
}

function changeNum(index){
for(var i=0; i<4; i ){
document.getElementById("fNum" i).className = "numOff";
}
document.getElementById("fNum" index).className = "numOff numOn";
}

function clearTimer(){
this.clearInterval(Timer);
}

function setTimer(){
Timer = window.setInterval(startChange, 3000)
}

function setIndex(index){
this.index = index;
this.startChange();
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn