嗨现在有这个排序
尝试所有不同的JQuery插件和JS教程,整天尝试在像amazons产品页面上的悬停库中进行图像交换,当您将鼠标悬停在缩略图上并显示在主图像上时。
我无法完成任何我尝试过的工作,下面是我一直在尝试的代码:
HTML(编辑)的
<div><img id="target" src="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-1-500x500.jpg" /></div>
<div class="left" id="dkProductImage">
<a rel="lightbox" title="Jessica Rabbit Original" href="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-1-500x500.jpg" class="thumb lightbox highlight"><img alt="Jessica Rabbit Original" src="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-1-500x500.jpg" width="100" height="100"></a>
<a rel="lightbox" title="Jessica Rabbit Original" href="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-5-74x74.jpg" class="thumb lightbox"><img alt="Jessica Rabbit Original" src="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-5-74x74.jpg" width="100" height="100"></a>
<a rel="lightbox" title="Jessica Rabbit Original" href="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-4-74x74.jpg" class="thumb lightbox"><img alt="Jessica Rabbit Original" src="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-4-74x74.jpg" width="100" height="100"></a>
<a rel="lightbox" title="Jessica Rabbit Original" href="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-3-74x74.jpg" class="thumb lightbox"><img alt="Jessica Rabbit Original" src="http://devilishkiss.com/image/cache/data/n6123-jessica_rabbit_original_lj-3-74x74.jpg" width="100" height="100"></a>
</div>
JS(编辑)的
<script language="javascript" type="text/javascript">
$("a.thumb").hover(function() {
$(this).addClass('highlight')
.siblings('a.highlight')
.removeClass('highlight');
$('#target').attr('src', this.href);
});
</script>
我有一个带有id目标的图像和一个带有拇指类的锚,为什么这个工作我迷失了:(
由于 乔
答案 0 :(得分:2)
是不是缺少jQuery启动功能?
$(document).ready(function(){
/* put the code here */
});
答案 1 :(得分:0)
要根据您的代码复制亚马逊图库的行为,请执行以下操作:
HTML
<div><img id="target" src="image1.jpg" /></div>
<div class="left" id="dkProductImage">
<a rel="lightbox" title="Jessica Rabbit Original" href="image1.jpg" class="thumb lightbox highlight"><img alt="Jessica Rabbit Original" src="image1_thumb.jpg"></a>
<a rel="lightbox" title="Jessica Rabbit Original" href="image2.jpg" class="thumb lightbox"><img alt="Jessica Rabbit Original" src="image2_thumb.jpg"></a>
<a rel="lightbox" title="Jessica Rabbit Original" href="image3.jpg" class="thumb lightbox"><img alt="Jessica Rabbit Original" src="image3_thumb.jpg"></a>
<a rel="lightbox" title="Jessica Rabbit Original" href="image4.jpg" class="thumb lightbox"><img alt="Jessica Rabbit Original" src="image4_thumb.jpg"></a>
</div>
JS
<script language="javascript" type="text/javascript">
$("a.thumb").hover(function() {
$(this).addClass('highlight')
.siblings('a.highlight')
.removeClass('highlight');
$('#target').attr('src', this.href);
});
</script>
您可以根据自己的喜好对其进行修改,但这应该可以了解它应该如何运作。
祝你好运注意:我添加了额外的“突出显示”类,以便您可以在鼠标位于缩略图(如亚马逊)上时设置样式,以指示当前在“目标”中查看的图像。如果你不想,你不需要使用它。