我很难从这个链接enter link description here获取图像切换机制来运行。这正是我需要的。伙计们,请帮助。我已经彻底检查了我的图像关系并切换了脚本的位置。
<div id="big-image">
<img id="main" src="images/goldenkoa_huge.png" width="400" height="400" alt="Canadian Maple, Engineered Luxury Click Vinyl Plank flooring"><br />
<a href="images/GoldenKoa-208x166_NEW3_big.gif" onclick="swap(this); return false;"><img src="images/GoldenKoa-208x166_NEW3.gif"></a>
<a href="images/picture2_big.jpg" onclick="swap(this); return false;"><img src="images/picture2_small.jpg"></a>
<a href="images/picture3_big.jpg" onclick="swap(this); return false;"><img src="images/picture3_small.jpg"></a>
我在头脑中加载了以下脚本(我还尝试将脚本移动到正文结束标记之上):
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script type="text/javascript">
function swap(image) {
document.getElementById("main").src = image.href;
}
</script>
</head>
答案 0 :(得分:0)
确保您设置的任何图片路径都是有效路径,或者您插入的脚本有效并且不会损坏您的JavaScript。
这是一个有效的例子:
function swap(image) {
document.getElementById("main").src = image.href;
}
<div id="big-image">
<img id="main" src="images/goldenkoa_huge.png" width="400" height="400" alt="Canadian Maple, Engineered Luxury Click Vinyl Plank flooring"><br />
<a href="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQV0TizaFIS4djTY-YgucL1dHDNseSPN9Ib74LVY40R1zYja6AV" onclick="swap(this); return false;"><img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQV0TizaFIS4djTY-YgucL1dHDNseSPN9Ib74LVY40R1zYja6AV" height="50px"></a>
<a href="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRqQOQHwPkBuYIcoUI4MpbDdbz0WUM2ql5l2HQ9keK-urytm8Vdgg" onclick="swap(this); return false;"><img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRqQOQHwPkBuYIcoUI4MpbDdbz0WUM2ql5l2HQ9keK-urytm8Vdgg" height="50px"></a>
</div>