Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  67] [ 2]  / answers: 1 / hits: 7181  / 10 Years ago, thu, april 10, 2014, 12:00:00

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.com/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>



More From » jquery

 Answers
20

You are only including the base jQuery library



<script src=http://ajax.googleapis.com/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.com/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.net/8YEyc/


[#46120] Thursday, April 10, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kourtney

Total Points: 368
Total Questions: 103
Total Answers: 85

Location: Bonaire
Member since Sat, May 1, 2021
3 Years ago
kourtney questions
Sun, Oct 4, 20, 00:00, 4 Years ago
Tue, Oct 29, 19, 00:00, 5 Years ago
Thu, Apr 4, 19, 00:00, 5 Years ago
Fri, Mar 1, 19, 00:00, 5 Years ago
;