イメージを変更するためにsetIntervalを使用しようとしていますが、新しいイメージではなくイメージが変更されたときにaltテキストのみが表示されます。私はJavaSciptの新機能ですので、ご提案があればこれを覚えておいてください。イメージを変更するときにsetIntervalエラーが発生する
<html>
<head>
<script type="text/javascript">
/* <![CDATA[ */
\t var changePic;
\t var pic = new Array(14);
\t var curPic = 0;
\t pug[0] = "gallery1.jpeg";
\t pug[1] = "gallery2.jpeg";
\t pug[2] = "gallery3.jpeg";
\t pug[3] = "gallery4.jpeg";
\t pug[4] = "gallery5.jpeg";
\t pug[5] = "gallery6.jpeg";
\t pug[6] = "gallery7.jpeg";
\t pug[7] = "gallery8.jpeg";
\t pug[8] = "gallery9.jpeg";
\t pug[9] = "gallery10.jpeg";
\t pug[10] = "gallery11.jpeg";
\t pug[11] = "gallery12.jpeg";
\t pug[12] = "gallery13.jpeg";
\t pug[13] = "gallery14.jpeg";
\t function change(){
\t \t if (curPic == 13)
\t \t \t curPic = 0;
\t \t else
\t \t \t ++curPic;
\t \t document.images[0].src = pic[curPic];
\t }
\t function startChange(){
\t \t if (changePic != null)
\t \t \t clearInterval(changePic);
\t \t changePic = setInterval("change()", 1000);
\t \t
\t }
/* ]]> */
</script>
</head>
<body>
\t <img src="gallery1.jpeg" alt="gallery_pic"/>
\t
\t <form action="">
\t \t <input type="button" value=" Change " onclick="startChange();" />
\t \t <input type="button" value=" Stop " onclick="clearInterval(changePic);" />
\t </form>
</body>
</html>
基本的に私はいくつかの画像を使用して簡単なスライドショーを作成しようとしています。 何かすべての助けが大変ありがとうございます。
私は本当に愚かな感じ。私は配列をコピーして貼り付けて、picではなくpugでtypoを作ったことに気付かなかった。 – TheGumGuy