0
我想创建一个重置按钮来重置我的图标的位置回到原来的位置..我不知道如何开始它..每当我拖放它不是在droppable它会回到原来的位置..我想当可以droppable里面的图标,当重置按钮按下它会重置图标的位置回到原来的位置。拖放重置按钮到原来的位置
的jsfiddle
https://jsfiddle.net/xInfinityMing/c0mmbspz/
HTML
<div id="dragIcons">
<img width="100px" height="100px"src="https://cdn2.iconfinder.com/data/icons/metro-uinvert-dock/256/MS_Office_Upload_Center.png">
<img width="100px" height="100px" src="https://cdn2.iconfinder.com/data/icons/metro-uinvert-dock/256/MS_Office_Upload_Center.png">
<img width="100px" height="100px" src="https://cdn2.iconfinder.com/data/icons/metro-uinvert-dock/256/MS_Office_Upload_Center.png">
<img width="100px" height="100px" src="https://cdn2.iconfinder.com/data/icons/metro-uinvert-dock/256/MS_Office_Upload_Center.png">
</div>
<div id="briefcase">
<div id="briefcase-full">
</div>
<div id="briefcase-droppable">
</div>
</div>
<button id="reset" type="button" onclick="doSomething()">Reset</button>
的Java
$(function() {
$("#dragIcons img").draggable({
revert: "invalid",
refreshPositions: true,
drag: function(event, ui) {
ui.helper.removeClass("end-draggable");
ui.helper.addClass("draggable");
},
stop: function(event, ui) {
ui.helper.addClass("end-draggable");
ui.helper.removeClass("draggable");
}
});
$("#briefcase-droppable").droppable({
drop: function(event, ui) {
$(this).parent().css('background-image','url("http://icons.iconarchive.com/icons/dtafalonso/yosemite-flat/512/Folder-icon.png")');
if ($("#briefcase").length == 0) {
$("#briefcase-droppable").html("");
}
ui.draggable.addClass("dropped");
$("#briefcase-droppable").append(ui.draggable);
}
});
});
感谢您的快速回复!非常感谢! –