【问题标题】:Jquery multiple dragable object not workingJquery多个可拖动对象不起作用
【发布时间】:2015-12-08 04:57:08
【问题描述】:

我正在尝试使用 Jquery 创建一个图像编辑器。如果需要将多个可分级图像制作到表面,我使用 Jquery 可分级。但它仅适用于 One 对象。当我添加了多个 gradable 时不起作用..

这是我的代码

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Draggable - Default functionality</title>
  <link rel="stylesheet" href="jquery-ui.css">
  <script src="jquery-1.10.2.js"></script>
  <script src="jquery-ui_1.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <style>
  .draggable {position: relative;}
  </style>

  <script>
  $(function() {
      d();
      r();
      function d(){
          $( ".draggable" ).draggable();
      }
      function r(){
          $( ".resizable" ).resizable();
      }

  });
  </script>
</head>
<body>
    <div class="ui-widget-content" style="width: 300px;height: 500px;">
        <img class="draggable resizable" src="t.jpeg" width="300" height="300" style="border: 1px dotted #ccc;"/>
        <img class="draggable resizable" src="logo.png" width="" height="" style="border: 1px dotted #ccc;"/>
        <div  class="draggable resizable">
            <p class="" style="border: 1px dotted #ccc;">Drag me around</p>
        </div>
    </div>
</body>
</html>

【问题讨论】:

  • 您可以查看以下链接:Multiple dragable
  • 尝试在每次添加新元素时销毁并重新初始化可拖动元素。

标签: jquery jquery-ui jquery-plugins


【解决方案1】:

尝试将 jQuery 代码更改为

jQuery(document).ready(function(){
 jQuery( ".draggable" ).draggable();
});

【讨论】:

    猜你喜欢
    • 2019-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-30
    • 2012-03-27
    • 1970-01-01
    相关资源
    最近更新 更多