使用 revert 选项进行拖放
说明
如果设置为 true,则元素在拖动结束时返回其原始位置。它还指定在拖动操作停止时是否调用 reverteffect 回调。默认为 false。
语法
以下是设置 revert 选项的简单语法。
new Draggable('element', {revert:true});
示例
<html> <head> <title>Draggables Elements</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script type = "text/javascript"src = "/javascript/scriptaculous.js"></script> <script type = "text/javascript"> window.onload = function() { new Draggable('myimage', {revert:true} ); } </script> </head> <body> <p>Drag it and then leave it to see the result:</p> <img id = "myimage" src = "/images/scriptaculous.gif"/> </body> </html>
这将产生以下结果 −