admin管理员组文章数量:1417029
I am trying to make a custom scrollbar and my javascript that is supposed to make the scrollbar draggable won't work. (I am using Chrome to test it)
Why is this returning an error?
// JavaScript Document
$(document).ready(function(){
$("#scrollbar-piece").draggable({axis: "y"});
Uncaught TypeError: undefined is not a function
})
Here is the html:
<head>
<meta charset="utf-8">
<script src=".10.2/jquery.min.js"></script>
<script src="theScriptThatHasAProblem.js"></script>
</head>
<body>
<div class="page-container">...</div>
<div id="scrollbar">
<div id="scrollbar-piece"></div>
</div>
</body>
I am trying to make a custom scrollbar and my javascript that is supposed to make the scrollbar draggable won't work. (I am using Chrome to test it)
Why is this returning an error?
// JavaScript Document
$(document).ready(function(){
$("#scrollbar-piece").draggable({axis: "y"});
Uncaught TypeError: undefined is not a function
})
Here is the html:
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis./ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="theScriptThatHasAProblem.js"></script>
</head>
<body>
<div class="page-container">...</div>
<div id="scrollbar">
<div id="scrollbar-piece"></div>
</div>
</body>
Share
Improve this question
asked Apr 10, 2014 at 19:58
An Original AliasAn Original Alias
2033 silver badges16 bronze badges
1
- 1 Are you missing a script include? jqueryUI perhaps? – n8wrl Commented Apr 10, 2014 at 20:00
3 Answers
Reset to default 2draggable is part of the jQuery UI library that you do not have referenced.
<script src="//ajax.googleapis./ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
Google CDN information
draggable documentation
You are only including the base jQuery library
<script src="http://ajax.googleapis./ajax/libs/jquery/1.10.2/jquery.min.js"></script>
to use jQuery draggable & droppable
include also
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
Edit: Also make sure the scripts are in the correct order. jQuery has to be loaded before jQuery UI, because it depends on it.
Check out this fiddle: http://jsfiddle/8YEyc/
You are missing jQuery UI library.draggable
is a ponent of jquery-ui this not not a part of jQuery.
You can download stable version from https://jqueryui./. Or, you can directly include that from google API as follows:
<script src="http://ajax.googleapis./ajax/libs/jquery/1.10.2/jquery.min.js"></script>
本文标签: javascriptWhy is my draggable method returning an errorStack Overflow
版权声明:本文标题:javascript - Why is my .draggable method returning an error? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745267363a2650683.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论