jQuery doesn't know function scrollTop

Mischka picture Mischka · Mar 21, 2011 · Viewed 14.9k times · Source

I want do create a div, which is scrollable in y-direction, but is fixed in x-direction. I already got help with it, here it works: http://jsfiddle.net/Q4dWz/

But somehow it doesn't want to work at home. I've downloaded the latest jquery:

wget -O jquery-1.5.min.js http://code.jquery.com/jquery-1.5.1.min.js

Everytime i call scrollTop I get it says that scrollTop is not a function :( http://gbimg.org/p.php?q=BRYaL I do not understand why it is not a function, and I don't understand, why Firebug says something about jquery 1.2.1 (look at the picture). Here is the code:

160 $(document).ready(function() {
161     $(window).scroll(function(){
162         var $win = $(window);
163         $('#zeit').css('top', 20 - $win.scrollTop());
164     });
165-238 some other functions
238 });

Answer

jball picture jball · Mar 21, 2011

Likely you have a collision with the $ variable in your home environment being set to two jQuery versions, and thus var $win = $(window); is setting $win to a jQuery 1.2.1 object without the required scrollTop function. If you look at the jQuery scrollTop page, you will see that scrollTop was introduced in version 1.2.6.