我正在寻找一种方法,可以在选择相关缩略图时在div
内显示更大的图像。下面是我试图用jquery,javascript或html5做的一个例子。什么方法最适合下面的布局
<div id="show_area">
show large non-thumb image here
</div>
<!-- selection list -->
<div id="view1">
<div class="info">
<span>Product: Info</span>
<span>Description: Info</span>
</div>
<a href="#"><img src="/thumb.jpg"></a>
</div>
<div id="view2">
<div class="info">
<span>Product: Info</span>
<span>Description: Info</span>
</div>
<a href="#"><img src="/thumb.jpg"></a>
</div>
<div id="view3">
<div class="info">
<span>Product: Info</span>
<span>Description: Info</span>
</div>
<a href="#"><img src="/thumb.jpg"></a>
</div>
<div id="view4">
<div class="info">
<span>Product: Info</span>
<span>Description: Info</span>
</div>
<a href="#"><img src="/thumb.jpg"></a>
</div>
<div id="view5">
<div class="info">
<span>Product: Info</span>
<span>Description: Info</span>
</div>
<a href="#"><img src="/thumb.jpg"></a>
</div>
<div id="view6">
<div class="info">
<span>Product: Info</span>
<span>Description: Info</span>
</div>
<a href="#"><img src="/thumb.jpg"></a>
</div>
答案 0 :(得分:1)
试试这个:
$('img').on('click',function(){
var old_img = this.src;
var new_img =old_img.split('_thb').join('')
$('#show_area').html('<img src="'+new_img+'" />');
});
示例here
答案 1 :(得分:0)
试试这个
$('a img').click(function() {
$('#show_area img').hide();
$('#show_area img').attr('src','https://lh4.googleusercontent.com/-v0soe-ievYE/AAAAAAAAAAI/AAAAAAABSw4/fNj-YFu4lgw/s120-c/photo.jpg').stop().fadeIn();
});
获取替代图片src