The use of JS image switch that is special effects display pictures

  • 2020-03-30 00:41:02
  • OfStack

In the production of web pages, we need to use JS special effects to show the picture, the following is the use of JS simple production of the picture switch.
 
<html> 

<head> 

<script type="JavaScript"> 

var srr = new Array(' Picture a ', ' Picture 2 ', ' Picture 3 ', ' Picture 4 ');//JS built-in array, data storage
var s = 0; 
function chage() { 
var img = document.getElementById('img1'); 
if (s <srr.length-1 ) { 
s++; 
} 
else { 
s = 0; 
} 
img.setAttribute('src', srr[s]); 
} 
function diaoyong() { 
setInterval(chage, 1000); 
} 

</script> 

</head> 

<body onLoad="diaoyong();"> 

</body> 

</html> 

Related articles: