1

我正在寻找一种在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>
4

2 回答 2

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+'" />');
});

这里有一个例子

于 2013-08-28T16:21:16.420 回答
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

小提琴:http: //jsfiddle.net/sarathsprakash/2MkVY/

于 2013-08-28T16:58:01.067 回答