如果我将 .thumbnail div 放在 #thumbhider 和 #thumbcontent div 之外,那么点击事件可以正常工作并且符合预期。目前他们没有。
网址: http: //www.samcoles.co.uk/dustbowl/guitars.php
我猜这与溢出有关:隐藏在包含的 div 上?我该如何解决这个问题?
的JavaScript:
//this is within $(document).ready function
$(".thumbnail").click(function () {
var IMAGE_DIR = "images/guitars/";
var img = $(this).find("img").attr("alt");
$("#mainphoto").attr("src", IMAGE_DIR + img);
if(captions) {
$("#imgcaption").text(captions[img]);
}
});
的CSS:
div.thumbnail { background-color: #000000; padding: 1px; float: left; width: 69px; height: 69px; cursor: pointer; }
div#thumbhider { width: 673px; height: 70px; overflow: hidden; margin: 0 auto; margin-top: 19px; position: relative; }
div.thumbcontent { height: 70px; background-color: #00ff00; width: 0 auto; display: inline; position: relative; }
的HTML:
<div id="thumbhider">
<div class="thumbcontent">
<div style="margin-right:15px;" class="thumbnail"><img alt="1.png" src="thumber.php?img=images/guitars/1.png&h=69&w=69"></div>
<div style="margin-right:15px;" class="thumbnail"><img alt="10.png" src="thumber.php?img=images/guitars/10.png&h=69&w=69"></div>
<!--etc....-->
<div style="clear:both;"></div>
</div>
</div>