Image source that can loop on array - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image


Image source that can loop on array

Demo Code

ResultView the demo in separate window

      <script type="text/javascript" language="JavaScript">
var i =0;//from  w w  w  .j a  v a2  s .  c o m
var trafficarray=["1.gif","2.gif","3.gif","4.gif"];
var image = document.getElementById("trafficlights");
function cycle()
  if (i>2) {i=-1};

      <img src="1.gif" id="trafficlights"> 
      <button onclick="cycle()">click me</button>  

Related Tutorials