<div class="codetitle"> <span><a style="CURSOR: pointer" data="11562" class="copybut" id="copybut11562" onclick="doCopy('code11562')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code11562"> <br> <br> <br> <br><title></title> <br><script type="text/javascript"> <BR>var numb = 0; <BR>var imgnumb = 1; <BR>function showimg() { <BR>//两张图片切换方法1 /*numb++; <BR>if (numb % 2 == 0) { <BR>document.getElementById('img1').setAttribute('src', 'images/1.jpg'); <BR>} <BR>else { <BR>document.getElementById('img1').setAttribute('src', 'images/2.jpg'); <BR>}*/ <BR>//两张图片切换方法2 /*if (numb == 0) { <BR>document.getElementById('img1').setAttribute('src', 'images/2.jpg'); <BR>numb = 1; <BR>} <BR>else { <BR>document.getElementById('img1').setAttribute('src', 'images/1.jpg'); <BR>numb = 0; <BR>}*/ <BR>} <BR>/图片轮换/多张 function imgfor() { <BR>imgnumb++; <BR>document.getElementById('img1').setAttribute('src', 'images/' + imgnumb + '.jpg'); <BR>if (imgnumb == 9) { <BR>imgnumb = 0; <BR>} <BR>} <BR>var clearid; <BR>function clearfun() { <BR>clearInterval(clearid); <BR>} <BR>clearid=setInterval(imgfor, 1000); <BR></script> <br> <br> <br><img alt="" id="img1" class="style1" src="images/1.jpg" style="max-width:90%" height="500px"> <br><input type="button" value="两张图片切换" onclick="showimg();"> <br><br> <br><input type="button" value="多张图片轮换" onclick="imgfor();;"> <br><br> <br><input type="button" value="结束执行" onclick="clearfun();"> <br> <br> <br> </div>