需要帮助编写jQuery for draggable

时间:2015-04-07 08:52:01

标签: jquery draggable

我正在网上上课,我们正在学习拖拉机。这是教师使用的代码(也许我做错了)使方形可拖动。它在firefox或chrome中对我不起作用。我的代码出了什么问题。

jQuery文件与我的html文件位于同一文件夹中。我根据他的指示复制了他的api链接,而不是谷歌api库。课程很旧。

如果有人检查我的代码并查看它是否适合他们,我将不胜感激。

感谢您的帮助。

<!doctype html>
<html>
<head>
<title>jQuery UI</title>

<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<script type="text/javascript" src="jQuery.min.js"></script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>


<style>

    #square {

    width:200px;
    height:200px;
    background-color:grey;

    }

</style>

</head>

<body>

<div id="square"></div>



<script>

    $("square").draggable();




</script>



</body>
</html>

1 个答案:

答案 0 :(得分:0)

您缺少

中的主题标签
$("square").draggable();

所以这样写:

$("#square").draggable();

因为div有id。 记得在引用类时使用点(。)和引用id时的#标签(#)。

相关问题