不能让JQuery Draggable插件工作吗? [英] Can't get JQuery Draggable plugin to work?

查看:119
本文介绍了不能让JQuery Draggable插件工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的 JQuery ,我正在尝试使用Draggable插件创建一个示例页面。该页面加载正常,但我无法在任何地方拖动我的< div> 标签。我一直在尝试复制这个演示。这是我的代码:

I'm very new to JQuery and I'm trying to create a sample page using the Draggable plugin. The page loads fine, but I'm not able to drag my <div> tag anywhere. I've been trying to copy this demo. Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
         <style type="text/css">
                #draggable { width: 150px; height: 150px; padding: 0.5em;  border: solid 1px black; cursor:pointer;}
         </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>


            <script src="scripts/jquery.js" type="text/javascript"/>
            <script src="scripts/jquery.ui.core.js" type="text/javascript"/>
            <script src="scripts/jquery.ui.draggable.js" type="text/javascript"/>
            <script src="scripts/jquery.ui.mouse.js" type="text/javascript"/>
            <script src="scripts/jquery.ui.widget.js" type="text/javascript"/>
            <script src="scripts/jquery-ui-1.8.13.custom.js" type="text/javascript" />

            <script type="text/javascript">
                $(document).ready(function() {
                    $("#draggable").draggable();
                });
            </script>


            <div class="demo" style="height: 500px; width: 500px;">
                <div id="draggable">
                    <p>Drag me around</p>
                </div>
            </div>
        </div>
        </form>
    </body>
    </html>

我只是想让它,所以我可以拖动我的draggable< div> 周围的演示< div> 。任何人都可以看到我缺少的东西?

I'm just trying to make it so I can drag my "draggable" <div> around in the "demo" <div> around it. Can anyone see what I'm missing?

推荐答案

您是否在您的页面上添加了jQuery UI脚本? 以下是最新版本的CDN链接。

Have you included the jQuery UI script on your page? Here is CDN link to the latest versions.

我使用 Html5Boilerplate 最佳做法:

    </form>

    <!-- Javascript at the bottom for fast page loading -->

    <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
    <script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.js" type="text/javascript"></script>
    <script type="text/javascript"> window.jQuery || document.write('<script src="js/libs/jquery-1.6.1.js">\x3C/script>')</script>

    <!-- Grab Google CDN's jQuery UI, with a protocol relative URL; fall back to local if necessary -->
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.js" type="text/javascript"></script>
    <script type="text/javascript"> $.ui || document.write('<script src="js/libs/jquery-ui-1.8.12.custom.min.js">\x3C/script>')</script>

    <!-- Scripts concatenated -->
    <script src="js/plugins.js" type="text/javascript"></script>
    <script src="js/script.js" type="text/javascript"></script>
    <!-- End scripts -->

</body>

这篇关于不能让JQuery Draggable插件工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆