Reputation: 87
<div id="aaa">sdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdfsdfas fasdfa asdf </div>
#aaa {
height: 100px;
width: 200px;
overflow: scroll;
}
$("#aaa").scrollTop = $("#aaa").scrollHeight;
Is possible doing scroll to down in this DIV in Firefox and in IE?
Upvotes: 0
Views: 1441
Reputation: 51030
$("#aaa").attr({ scrollTop: $("#aaa").attr("scrollHeight") });
Replace attr
s with prop
for jQuery 1.6+.
Upvotes: 0
Reputation: 5286
Your code is a bit wrong, as scrollTop
in jQuery is actually a function, not a property. And scrollHeight is a native javascript property, not related to jQuery. So you'll want to do something like this :
$('#aaa').scrollTop($("#aaa")[0].scrollHeight);
That being said, you should probably cache your div reference in a variable instead of getting it two times, like this :
var $aaa = $('#aaa');
$aaa.scrollTop($aaa[0].scrollHeight);
Upvotes: 2