Vinayak
Vinayak

Reputation: 80

Scroll Position to last in jQuery

How can I scroll my div with class main to last scroll position

means the scroll bar goes automatically at the end

Upvotes: 0

Views: 103

Answers (3)

Adam Neuwirth
Adam Neuwirth

Reputation: 547

If you want to animate it, use this code

$("html, body").animate({ scrollTop: $(document).height() }, "slow");

Make sure you have jQuery on the page you're using this code on

Upvotes: 0

Jorge Omar MH
Jorge Omar MH

Reputation: 501

you can use a trick if you put a element at least of the div and the element with an id you can use this code

window.location = ('#id')

Upvotes: 1

Jorge Omar MH
Jorge Omar MH

Reputation: 501

could you try with scrollTop

document.querySelector('.main').scrollTop = document.querySelector('.main').scrollHeight

so you change the height by top position of the scroll

Upvotes: 1

Related Questions