拖放及魅影选项


说明

此选项用于确定是否应该克隆可拖动项以进行拖动,让原件待在原地,直到克隆项被放下。默认为否。

当魅影设置为真时,拖动操作似乎将原始目标元素留在原处,而元素的半透明版本会被拖动。

语法

以下是使用魅影选项的简单语法。

new Draggable('element', {ghosting: true or false });

示例

<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', {ghosting:true});
         }
      </script>
   </head>

   <body>
      <p>Try to drag following image and see how it leaves it
         original image at its place. Later change ghosting to false
         and repeat the exercise</p>
      <img id = "myimage" src = "/images/scriptaculous.gif"/>
   </body>
</html>

将产生以下结果 −

scriptaculous_drag_drop.htm
广告
© . All rights reserved.