以下代码在单击按钮时创建图像。您可以看到在 firebug DOM 中创建的图像。但是高度和宽度是0px。未检测到图像尺寸。
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/themes/base/jquery-ui.css" type="text/css" media="all">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js" type="text/javascript">
</script>
<button style="width:100px; height:30px;">test</button>
<p style="height:400px; width:500px;border:2px solid red;"></p>
<script type="text/javascript">
var spanid = 1;
$("button").click(function() {
var elm = $('<img id=spanId' + spanid + ' src="http://www.carsyouwilldrive.com/wp-content/uploads/2009/06/futurecar1.jpg"/>');
elm.resizable().parent().draggable({
cursor: "move"
}).appendTo('p');
spanid++;
});</script>