18
我有一些div的圖像,當我點擊這些圖像時,我想讓另一個div打開,並點擊了該圖像。將圖像src設置爲另一個圖像jquery
JS
$('.examples img').click(function() {
var loc = $(this).attr("src");
$('#image-zoom').attr("src",loc);
});
HTML
<div class="container examples" >
<div id="image-zoom">
<img class="img-thumbnail zoom" src="" alt="dental">
</div>
<div class="row">
<div class="col-sm-12">
<img id="zoom" class="img-thumbnail zoom" src="images/01.png" alt="dental">
<img class="img-thumbnail zoom" src="images/02.png" alt="dental">
<img class="img-thumbnail zoom" src="images/03.png" alt="dental">
</div>
</div>
<div class="row">
<div class="col-sm-12">
<img class="img-thumbnail zoom" src="images/04.png" alt="dental">
<img class="img-thumbnail zoom" src="images/05.png" alt="dental">
<img class="img-thumbnail zoom" src="images/06.png" alt="dental">
</div>
</div>
</div>
當我試圖隱藏在div它的工作,所以我有錯誤的語法我覺得
什麼? – ambarox
'#image-zoom''不是'img'標籤,所以它不能擁有'src'屬性 – JFK