culebrón
culebrón

Reputation: 36513

jQuery 1.5 scrollTop method raises exceptions

What is this error and what can I do about this?

I made a simple div with overflow-y: scroll style and some content, but here's what happens when I try using jQuery.scrollTop on it (I run this from Developer Tools shell):

$('#s').scrollTop(100)

scrolls, but shows this:

Uncaught TypeError: Object 10 has no method 'apply'
jQuery.event.handle, jquery-1.5.2.js:2568
jQuery.event.add.elemData.handle.eventHandle, jquery-1.5.2.js:2207

I see this message every time I use scrollTop. I have Chromium 14.0.835.202 (Developer Build 103287 Linux)

Upvotes: 0

Views: 964

Answers (2)

Murtaza Khursheed Hussain
Murtaza Khursheed Hussain

Reputation: 15336

Let the DOM ready before you do any action on it.

$(function() {
    $('#b').click(function() {
        $('#s').scrollTop(100);
    });
});

Upvotes: 0

pnuts
pnuts

Reputation: 276

I get no problem in my test(see below), maybe you break something by accident. Show me your whole code.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<div id="s" style="overflow-y:scroll;height:100px;">
  some content ...
</div>
<input id="b" type="button" value="scrollTop" />
<script>
  $('#b').click(function() {
    $('#s').scrollTop(100);
  });
</script>

Upvotes: 1

Related Questions