拖放及還原選項


說明

如果設為 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>

將產生以下結果 −

scriptaculous_drag_drop.htm
廣告