JScript code<style type="text/css"> div{ margin-top:10px; }</style><script type="text/jscript">var i=1;var t=null;function doImage(i){if(i>6){ clearInterval(t);return; };var mainDiv= document.getElementById('MainDiv');var img= document.createElement('img'); img.src=""+ i+".jpg"; img.height=50; img.width=100;var div= document.getElementById('div'+ i); div.appendChild(img); img.οnclick=function(){var mainDiv= document.getElementById('MainDiv'); mainDiv.firstChild.src=this.src; } mainDiv.firstChild.src= img.src; } window.οnlοad=function(){var mainDiv= document.getElementById('MainDiv');var image= document.createElement('img'); mainDiv.appendChild(image); image.height=100; image.width=200; t= setInterval(function(){ doImage(i++); },1000); }</script><div><div style="float:left; width:100px;"><div id="div1"></div><div id="div2"></div><div id="div3"></div></div><div style="float:left; width:200px; padding:50px;" id="MainDiv"></div><div style="float:left; width:100px;"><div id="div4"></div><div id="div5"></div><div id="div6"></div></div></div>
js实现图片切换
最新推荐文章于 2023-04-03 21:30:47 发布