定义和用法

当带有布尔值revert选项的draggable停止拖拽时,返回draggable(或它的助手)到原始位置


示例

<!DOCTYPEhtml><html><head><metacharset="utf-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><title>jQueryUI拖动(Draggable)-还原位置</title><linkrel="stylesheet"href="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.css"><style>#draggable1,#draggable2{width:200px;height:200px;padding:0.5em;float:left;margin:010px10px0;}#draggablep{cursor:move;}</style></head><body><divid="draggable1"class="ui-widget-content"><p>还原</p></div><divid="draggable2"class="ui-widget-content"><p>还原助手</p></div><scriptsrc="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/external/jquery/jquery.js"type="text/javascript"></script><scriptsrc="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script><script>$(function(){$("#draggable1").draggable({revert:true});$("#draggable2").draggable({revert:true,helper:'clone'});});</script></body></html>


输出