我有一张背景图片,我想执行这样的功能:当单击一个按钮时,第二张图片会添加到背景图片上方。该图像是通过单击我的代码添加的,但不在背景图像上方。此外,我的图像可以拖动,如果我提到 width
和 height
div
内
为了更好的解释,附上代码:
$(document).ready(function(){
$("button").click(function(){
$("#currentimage").after('<img id="dragable" src="http://s25.postimg.org/pi8ruls3z/image.jpg" width="200px" height="auto" />');
$("#dragable").draggable()
});
});
最佳答案
试试这个:
$(document).ready(function(){
$("button").click(function(){
$("#currentimage").html('<img id="dragable" src="http://s25.postimg.org/pi8ruls3z/image.jpg" width="200px" height="auto" />'+"<br /><img src=\"http://s25.postimg.org/v554s2umn/man_looking_at_sunset.jpg\" width=\"200px\" style=\"height: auto; z-index: 0;\"/>");
$("#dragable").draggable()
});
});
关于jquery - 在另一个图像上方显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22552127/