我附上了一个可用的jsFiddle。是的,它可以工作,但是我试图达到的似乎超出了我的经验。点击jQuery图片缩略图更改
目前它显示一排缩略图,当你点击其中一个缩略图时,它将显示与特色图像相同的图像。
我需要做的是能够将缩略图显示为与显示为特色图像的图像不同的图像。
例如,我有一个产品特色图片,该图片也将放大此图片的裁剪版本作为缩略图。
缩图1(放大裁剪版本)/特色图片1
缩图2(放大裁剪版本)/特色图片2
缩图3(放大裁剪版本)/特色图片3
https://jsfiddle.net/gq74rgc3/2/
<img id="image" src="http://www.981powerfm.com.au/images/stories/2014/09/happy_animal_5.jpg" border="0" />
<img src="http://www.981powerfm.com.au/images/stories/2014/09/happy_animal_5.jpg" class="thumb" width='100px' />
<img src="http://smartyvet.com/site/wp-content/uploads/2014/05/happy5.jpg" class="thumb" width='100px' />
<img src="http://www.telegram.ee/wp-content/uploads/2013/11/a.aaa-Happy-animals.jpg" class="thumb" width='100px' />
$(document).ready(function() {
$(".thumb").click(function() {
var dir = $(this).attr("src");
$('#image').hide();
$('#image').fadeIn('fast');
$('#image').attr("src", dir);
});
});
这是否有道理?
任何帮助将不胜感激。
干杯
你需要的是当您单击缩略图出现随机图像,而不是点击缩略图? – Bak
@Bak不是随机图像,而是缩略图的相关图像。 – tebrown
[尝试在点击时更改图片并再次返回]可能的重复(http://stackoverflow.com/questions/24811672/trying-to-change-an-image-on-click-and-back-again) –