質問編集履歴
2
【追記】 写真の追記とそのJSコード
title
CHANGED
File without changes
|
body
CHANGED
@@ -88,4 +88,28 @@
|
|
88
88
|
|
89
89
|
removeメソッドを使えば、HTMLとして出力した画像を切り替えられると予想しましたが、失敗しました。
|
90
90
|
removeメソッドが効かず一度だけ画像が変わった後、無限に画像がランダムに2枚ずつビュー上で表示されます。
|
91
|
-
このため、ページ自体が無限に縦長になっていきます。
|
91
|
+
このため、ページ自体が無限に縦長になっていきます。
|
92
|
+
|
93
|
+
|
94
|
+
PS 写真の追記とそのJSコードです。
|
95
|
+

|
96
|
+
|
97
|
+
```JavaScript
|
98
|
+
var rPicList = new Array(
|
99
|
+
"pictures/1.png","pictures/2.png","pictures/3.png","pictures/4.png","pictures/5.png",
|
100
|
+
"pictures/6.png","pictures/7.png","pictures/8.png","pictures/9.png","pictures/10.png",
|
101
|
+
"pictures/11.png","pictures/12.png","pictures/13.png","pictures/14.png","pictures/15.png",
|
102
|
+
"pictures/16.png","pictures/17.png","pictures/18.png","pictures/19.png","pictures/20.png",
|
103
|
+
"pictures/21.png","pictures/22.png","pictures/23.png","pictures/24.png","pictures/25.png",
|
104
|
+
"pictures/26.png","pictures/27.png","pictures/28.png","pictures/29.png");
|
105
|
+
|
106
|
+
slideshow_timer();
|
107
|
+
function slideshow_timer(){
|
108
|
+
var pNum = Math.floor(Math.random() * rPicList.length);
|
109
|
+
var printHtml = new Image();// imgタグを生成
|
110
|
+
printHtml.src = rPicList[pNum];
|
111
|
+
document.querySelector('.pic_container > img').remove();
|
112
|
+
document.querySelector('.pic_container').appendChild(printHtml);
|
113
|
+
setTimeout("slideshow_timer()",5000);
|
114
|
+
}
|
115
|
+
```
|
1
誤字の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
表題の通り、JSで画像を5秒間隔で2枚同時に切り替えるプログラムの書き方でつまずいています。
|
2
2
|
|
3
|
-
HTMLとCSSは問題なさそうですが、**JSで2回目以降の画像切り
|
3
|
+
HTMLとCSSは問題なさそうですが、**JSで2回目以降の画像切り替えができません。**
|
4
4
|
JSでどのように記述したら、正しくCSSを反映させたまま画像を切り替え表示させ続けることが可能でしょうか?
|
5
5
|
|
6
6
|
お手数をおかけしますが、ご助言のほどお願いします。
|