jQuery UI-Draggable不是函数吗?
我试图在页面上的某些div上使用可拖动效果,但是每当我加载页面时,都会收到错误消息:
I've trying to use the draggable effect on some divs on a page, but whenever I load the page, I get the error message:
Error: $(".draggable").draggable is not a function
我环顾四周,似乎其他人遇到了这个问题,因为他们没有包括jQuery UI javascript文件,但是我绝对有.
I've had a look around it seemed other people were having this problem as they had not included the jQuery UI javascript file, but I definitely have.
以下是我页面的标题标签内:
The following is within the head tag of my page:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
有人可以提出解决方案吗?
Can anyone suggest a solution?
任何建议表示赞赏.
谢谢.
快速编辑,我也将jquery工具js包含在页面的顶部,如果我删除了它,就可以了.有没有人设法使这两个一起工作?
Quick edit, I also have the jquery tools js included in the head of the page, if I remove this it works OK. Has anyone managed to get these two working together?
发生的常见原因是,如果您在加载jquery之后也没有同时加载jqueryui.
A common reason occurs is if you don't also load jqueryui after loading jquery.
例如:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
编辑. 将每个库的版本号替换为 jquery 和 jqueryui .
EDIT. Replace the version number for each library with appropriate or latest values for jquery and jqueryui.
如果这不能解决问题,请查看许多其他答案中的建议.
If this doesn't solve the issue, review suggestions in the many other answers.