Here, I' want to implement some code to get the images when click on it.So,some example code that used.
在这里,我想实现一些代码来点击它时获取图像。所以,使用了一些示例代码。
<div class="click"><img class="img1" src ="img/1.png"/></div>
<div class="click"><img class="img2" src ="img/2.png"/></div>
$(document).ready(function(){
$('.click).click(function(){
// some code will be implement here
$('.content').html();
});
});
<div class="content"></div> <!-- the image will show here -->
2 个解决方案
#1
1
You can clone the image:
你可以克隆图像:
$(document).ready(function () {
$('.click').click(function () {
var $img = $(this).find('img').clone();
$('.content').html($img);
});
});
#2
1
Try this
$('.click').click(function() {
$('.content').html($(this).find('img').clone());
});
#1
1
You can clone the image:
你可以克隆图像:
$(document).ready(function () {
$('.click').click(function () {
var $img = $(this).find('img').clone();
$('.content').html($img);
});
});
#2
1
Try this
$('.click').click(function() {
$('.content').html($(this).find('img').clone());
});