2014-06-16 88 views
0

我得到了多个div的缩略图,该div还包括一个内部div与一个标准的图片,点击拇指将显示内部div中的图片。JQuery图像div点击

问题:当我打开另一个div时,最后打开的图片仍会显示。

JQuery的

$('.thumbsmall img').click(function(){ 
    $(".imageshow").html($("<img>").attr("src", this.src)); 
}) 

HTML

<div class="modal-body"> 
    <h2>3D automotive visualisatie</h2> 
    <div class="imageshow"></div> 
    <p>Visualisatie 3D automotive</p> 
    <ul class="list-inline item-details"> 
     <li>Klant: <strong><a>Eigen project</a></strong></li> 
     <li>Datum: <strong><a>WIP</a></strong></li> 
     <li>Wat?: <strong><a>3D productie</a></strong></li> 
     <li>Tags: <a>3D, vray, automotive, hdri</a></li> 
    </ul> 
    <button type="button" class="btn btn-lg btn-success" data-dismiss="modal"> 
     <i class="fa fa-times"></i> Sluit 
    </button> 
</div> 
<div class="thumbsmall"> 
    <ul> 
     <li><img src="img/3d15.png" alt="3d design"></li> 
     <li><img src="img/3d3.png" alt="3d design"></li> 
    </ul> 
</div> 

链接 http://robbyquintiens.be 坐落在组合部分

感谢: )

+2

'$(“”)'不是有效的选择器 –

+0

尝试一次: 首先,在点击函数里面清除存在于div内的当前图像。 然后插入你正在使用的行: $(“。imageshow”)。html($(“”).attr(“src”,this.src)); – Tanul

回答

0

试试这个:

$('.thumbsmall img').click(function(){ 
    $(".imageshow").html($('img.class-of-the-other-image').prop("src", $(this).prop('src')));//newer jquery 
    $(".imageshow").html($('img.class-of-the-other-image').attr("src", $(this).attr('src')));// older jquery 
}) 

不要忘了把类的最其它图像上的HTML或更改要的类名。