js dynamic setting div background images and scrolling display

var imgs = [ "../ img / index / bgstyle / style1 / index_top_bg2.jpg", "../img/index/bgstyle/style1/index_top_bg3.jpg", "../img/index/bgstyle/style1/ index_top_bg1.jpg "]; // (set image desired to be displayed) 
var I = 0; 
var = document.getElementsByClassName head (" div-header ") [0]; // Get the object dIV 
head.style.background = "url (../ img / index / bgstyle / style1 / index_top_bg2.jpg)"; // set the picture image for the path initial picture 
        function Time () { 
               I ++;    
               I = I%. 3; // over 2 take the remainder, to ensure circulation between 0,1,2 
               head.style.background = "URL (" + imgs [I] + ")";    
        } 
        the setInterval (Time, 5000); // call TIME1 loop () function, interval 2000ms 
        // the setInterval () function, the specified period (in milliseconds) to the calling function or expression 
}

 

Guess you like

Origin www.cnblogs.com/luo1240465012/p/11287727.html