【问题标题】:Error: Object doesn't support property or method 'draggable'错误:对象不支持“可拖动”属性或方法
【发布时间】:2014-06-10 10:43:10
【问题描述】:

我一直收到这个错误:

错误:对象不支持“可拖动”属性或方法

我已包含此代码运行所需的所有必要脚本。 我做错了什么?

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <script src="@Url.Content("~/Scripts/jquery-1.10.2.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui.js")" type="text/javascript"></script>
    <link rel="stylesheet" href="/resources/demos/style.css">
    <style>
        #test {
            width: 150px;
            height: 150px;
            padding: 0.5em;
        }
    </style>
    <script>
        $(function () {
            $("#test").draggable();
        });
    </script>
</head>
<body>

    <div id="test" class="ui-widget-content">
        <p>Drag me around</p>
    </div>


</body>
</html>

【问题讨论】:

  • 你确定jquery ui文件路径正确吗
  • 是的,路径正确
  • 更改 CDN 托管版本的 jquery 和 jquery ui 路径只是为了测试 - 可能是您的 UI 文件没有可拖动的部分
  • 我检查了 jquery ui 的可拖动功能。该函数包含在文件中。

标签: jquery asp.net jquery-ui


【解决方案1】:

在内部样式表中将 id “#draggable”更改为“#test”。因为您的 html 中没有可拖动的 id。

#test   {
            width: 150px;
            height: 150px;
            padding: 0.5em;
        }

【讨论】:

  • 从#draggable 更改为#test。还是不行。
【解决方案2】:

试试这个

<div id="main">
   <div id="test" class="ui-widget-content">
        <p>Drag me around</p>
   </div>
</div>

【讨论】:

    猜你喜欢
    • 2013-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-31
    • 2011-08-25
    • 2012-01-20
    • 1970-01-01
    相关资源
    最近更新 更多