下面的代碼在點擊按鈕時創建一個圖片。你可以看到在螢火蟲DOM中創建的圖像。但高度和寬度是0px。圖像尺寸未被檢測到。jQuery可調整大小的圖片排除問題
<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>
感謝。按預期工作。我不知道有關disableSelection()。我發現它特別適用於文本框。肯定會利用它。 – Hussein 2011-01-12 20:11:18