ページの読み込みごとに、配列から 1 つの div をランダムに生成しようとしています。
以下を作成するために、いくつかのランダム画像ジェネレーターからビットをまとめることができました。
配列内の [0] に画像が含まれている場合、残りの部分と同様に、すべてが正常に機能します。[0] の画像を div またはビデオに置き換えると、何も表示されず、ページが空白になります。
私が間違っている提案はありますか?
<link rel="stylesheet" type="text/css" href="style.css" >
<script type="text/javascript">
function random()
{
video = new Array(4);
video[0] = "<div class="clip"> </div> ";
video[1] = "<a href=''><img src='http://lorempixel.com/output/city-q-c-640-480-3.jpg' alt='' /></a>";
video[2] = "<a href=''><img src='http://lorempixel.com/output/fashion-q-c-640-480-6.jpg' alt='' />";
video[3] = "<a href=''><img src='http://lorempixel.com/output/technics-q-c-640-480-1.jpg' alt='' />";
for(var i = 0; i < video.length; i++)
{
index = Math.floor(Math.random() * video.length);
document.write(video[index]);
}
}
</script>
</head>
<body>
<script type="text/javascript">
random();
</script>
</body>