JavaScriptでインデックス配列の説明にリンクを追加するにはどうすればよいですか? 私のコードは以下です、ありがとう。push メソッドを使ってみましたが、showpic 関数と競合していたようです。まったくわからないので、どなたか助けていただければ幸いです。
<script type="text/javascript">
mypic = new Array();
mypic[0] = ["images/Lg_image1.jpg", "Large image 1 description."] //I want to add an HTML link to a website at the end of this array
mypic[1] = ["images/Lg_image2.jpg", "Large image 2 description."] //I want to add an HTML link to a website at the end of this array
function showpic2(n) {
document.getElementById("mainpic2").src = mypic[n][0]
document.getElementById("mycaption2").innerHTML = mypic[n][1]
count = n
}
count = 0;
function next() {
count++
if (count == mypic2.length) {
count = 0
}
document.getElementById("mainpic2").src = mypic2[count][0]
document.getElementById("mycaption2").innerHTML = mypic2[count][1]
}
function prev() {
count--
if (count < 0) {
count = mypic2.length - 1
}
document.getElementById("mainpic2").src = mypic2[count][0]
document.getElementById("mycaption2").innerHTML = mypic2[count][1]
}
</script>
<body>
<div id="container">
<div class="menu1">
<ul>
<li><a href="#">Link 1</a> </li>
</ul>
<ul>
<li><a href="#">Link 2</a> </li>
</ul>
</div>
<div id="large"> <img src="images/Lg_image1.jpg" class="mainpic2" id="mainpic2"> </div>
<div id="thumbs2"> <a href="javascript:showpic2(0)"><img src="images/sm_image1.jpg" alt="image1"/></a> <a href="javascript:showpic2(1)"><img src="images/sm_image2.jpg" alt="image2"/></a> </div>
<div id="mycaption2">Large image default description. </div>
<div id="logohome"> <img src="images/#.png" alt="" /> </div>
<div id="homebox"> <img src="images/homebox1.png" alt="" /> </div>
</div>
</body>
</html>