我有一个背景图片,我想执行一些功能,即单击按钮时,会在背景图片上方添加另一个图片。通过单击我的代码添加图像,但不要在背景图像上方。此外,我的图片具有拖动功能,并且如果要提及div
和width
,我希望仅在height
内部使此拖动成为可能
为了更好地解释,代码中包含以下代码:
jsfiddle.net
$(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()
});
});