<div class="codetitle"> <span><a style="CURSOR: pointer" data="24717" class="copybut" id="copybut24717" onclick="doCopy('code24717')"><u>複製程式碼</u></a></span>程式碼如下:</div> <div class="codebody" id="code24717"> <br><script type="text/javascript"> <BR>var i = 1;變數n; <BR>function showImg() { <BR>if (document.getElementById('img').getAttribute("src") == "images/1.jpg") { <BR>document. getElementById('img') .setAttribute("src","images/2.jpg"); <BR>} <BR>else { <BR>document.getElementById('img').setAttribute("src"," images/1.jpg"); <BR>} <BR>} <BR>function showImg1() { <BR>document.getElementById('img').setAttribute("src", "images/" i ".jpg ");我; <BR>如果(i > 10) <BR>{ <BR>i = 1; <BR>} <BR>} <BR>function show() { <BR>n=setInterval(showImg1, 500); <BR>} <BR>函數show1() { <BR>clearInterval(n); <BR>} <BR></腳本> <BR></頭> <BR><身體> <BR> <img id="img" alt="" src="images/1.jpg" style="max-width:90%" style="max-width:90%" /> <BR><input id="Button1" type="button" value="換圖片" onclick="showImg()" />> <BR><input id="Button2" type="button" value="切圖" onclick="showImg1()" />> <BR><input id ="Button3" type="button" value="輪換" onclick="show()" />> <BR><input id="Button4" type="button" value="停止輪換" onclick="show1( )" />> <BR></身體> <BR></script> </div>