如何在 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>