2014-06-16 5 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에 클래스 - 중 - 다른 이미지를 넣어 또는 당신이 원하는 클래스 이름을 변경할 수 있습니다.

관련 문제