将图像src设置为另一个图像jquery [英] Set image src to another image jquery
本文介绍了将图像src设置为另一个图像jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个div有一些图像,当我点击那些图像,我想要另一个div打开与我点击的图像。
I have a div with some images, and when I clicked on those images I want another div to open with that Image that I clicked.
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它的工作,所以我有错误语法我认为
When I try to Hide the div its working, so I have error in syntax I think
推荐答案
更改图片的 src
,而不是div:
Change the src
of the image, not of the div:
$('#image-zoom img').attr("src",loc);
这篇关于将图像src设置为另一个图像jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文