<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><!DOCTYPE html PUBLIC "-//W3C/ /DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><html xmlns="http://www.w3 .org/ 1999/xhtml"> <br><head> <br><title></title> <br><script type="text/javascript"> <br>var numb = 0 ; <br>var imgnumb = 1; <br>function showimg() { <br>//2 つの画像の切り替えメソッド 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枚の写真の切り替え方法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>/画像回転/複数関数 imgfor() { <br>imgnumb; <br>document.getElementById('img1') setAttribute('src', 'images/' imgnumb '.jpg'); <br>if (imgnumb == 9) { <br>imgnumb = 0; <br>} <br>} <br>var clearid; 🎜>関数 clearfun() { <br>clearInterval(clearid); <br>clearid=setInterval(imgfor, 1000); <br> </head> <body> <br><img alt="" id="img1" class="style1" src="images/1.jpg" width="500px" height="500px" /> ;input type="button" value="2 つの画像を切り替える" onclick="showimg(); /> <br><input type="button" value="複数画像を回転する" onclick="imgfor();;" /> <br><br /> <br><input type="button" value="実行を終了" onclick="clearfun();" / > <br><br><br> </div>