0
http://jsbin.com/xidoruheti/edit?html,css,js,output爲什麼我不能拖後,我指定幫手股利:「克隆」
根據API:http://api.jqueryui.com/draggable/#option-helper
我不知道爲什麼在div變得undraggable我指定幫手後:「克隆'
http://jsbin.com/xidoruheti/edit?html,css,js,output爲什麼我不能拖後,我指定幫手股利:「克隆」
根據API:http://api.jqueryui.com/draggable/#option-helper
我不知道爲什麼在div變得undraggable我指定幫手後:「克隆'
試試這個。實際上拖動工作正常,但你無法看到元素。因爲你爲#id指定了樣式,但在使用克隆選項拖動時,插件將刪除id屬性。因此,您無法看到被拖動的元素。
$("#toDrag").draggable({
helper: "clone"
});
$("#toDragId").draggable({
helper: "clone",
start: function(e, u) {
$(u.helper).attr("id", "toDragId");
}
});
.clone,
#toDragId {
width: 100px;
height: 100px;
background: blue;
}
#toDragId {
width: 100px;
height: 100px;
background: green;
}
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div id="toDrag" class="clone"></div>
<br>
<div id="toDragId"></div>
它的工作原理。看來我不能使用id作爲選擇器來設計div元素。但是怎麼來? –
你可以使用,但jQuery的可拖動插件刪除克隆元素的id屬性,同時拖動。使其工作,您可以添加id屬性克隆在'start'事件 –
檢查更新的答案,並請標記答案接受,如果它幫助你。 –