我在尝试将图像描述放在主图像下面时遇到了很多麻烦,但是在Dreamweaver中创建的图像库中的缩略图上方,点击图像交换。我遇到问题的页面在这里:
http://marychatham.com/work.html
“瓷器.14.5”H x 8“W”是图像交换发生时我想要更改的描述。
这是我的代码:
<div id="MainImage"><img src="images/MaryChatham_01.png" name="main" id="main"></div>
<div id="Description">
<h4>Porcelain. 14.5" H x 8" W.</h4>
</div>
<div id="Thumbs">
<div id="Thumb1"><a href="javascript:;" onClick="MM_swapImage('main','','images/MaryChatham_01.png',1)"><img src="images/MaryChatham_Thumbnail_01.png" alt="Por" name="t1" id="t1" border="0"></a></div>
<div id="Thumb2"><a href="javascript:;" onClick="MM_swapImage('main','','images/MaryChatham_02.png',1)"><img src="images/MaryChatham_Thumbnail_02.png" alt="Ce" name="t2" id="t2" border="0"></a></div>
<div id="Thumb3"><a href="javascript:;" onClick="MM_swapImage('main','','images/MaryChatham_03.png',1)"><img src="images/MaryChatham_Thumbnail_03.png" name="t3" id="t3" border="0"></a></div>
<div id="Thumb4"><a href="javascript:;" onClick="MM_swapImage('main','','images/MaryChatham_04.png',1)"><img src="images/MaryChatham_Thumbnail_04.png" name="t4" id="t4" border="0"></a></div>
<div id="Thumb5"><a href="javascript:;" onClick="MM_swapImage('main','','images/MaryChatham_05.png',1)"><img src="images/MaryChatham_Thumbnail_05.png" name="t5" id="t5" border="0"></a></div>
<div id="Thumb6"><a href="javascript:;" onClick="MM_swapImage('main','','images/MaryChatham_06.png',1)"><img src="images/MaryChatham_Thumbnail_06.png" name="t6" id="t6" border="0"></a></div>
<div id="Thumb7"><a href="javascript:;" onClick="MM_swapImage('main','','images/MaryChatham_07.png',1)"><img src="images/MaryChatham_Thumbnail_07.png" name="t7" id="t7" border="0"></a></div>
<div id="Thumb8"><a href="javascript:;" onClick="MM_swapImage('main','','images/MaryChatham_08.png',1)"><img src="images/MaryChatham_Thumbnail_08.png" name="t8" id="t8" border="0"></a></div>
</div>
</div>
</div>
</body>
</html>
感谢您的帮助。我被困了几天。
答案 0 :(得分:1)
在“description”div中为h4
标记id
;类似的东西:
<div id="Description">
<h4 id="caption">Porcelain. 14.5" H x 8" W.</h4>
</div>
然后为每个a
title
提供您希望该图片标题的内容。例如:
<div id="Thumb1">
<a href="javascript:;" title="This is my sweet caption." onClick="MM_swapImage('main','','images/MaryChatham_01.png',1)">
<img src="images/MaryChatham_Thumbnail_01.png" alt="Por" name="t1" id="t1" border="0">
</a>
</div>
然后,不要使用您正在使用的MM_swapImage
内容,请使用:
onClick = "document.getElementById('main').src = 'images/MaryChatham_01.png'; document.getElementById('caption').innerHTML = this.title;"
你也不需要那个href="javascript:;"
的东西;只需href=""
。所以每个拇指看起来都是这样的:
<div id="Thumb1">
<a href="" title="This is my sweet caption." onClick="document.getElementById('main').src = 'images/MaryChatham_01.png'; document.getElementById('caption').innerHTML = this.title;">
<img src="images/MaryChatham_Thumbnail_01.png" alt="Por" name="t1" id="t1" border="0">
</a>
</div>
如果您了解一些超级基本的Javascript,这实际上是一件非常简单的事情。我真的建议花些时间学习一些基础知识;你会惊讶于你能做到的。