0

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

means the scroll bar goes automatically at the end

Vinayak
  • 80
  • 8

3 Answers3

1

could you try with scrollTop

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

so you change the height by top position of the scroll

Jorge Omar MH
  • 491
  • 5
  • 7
1

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')
Jorge Omar MH
  • 491
  • 5
  • 7
0

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

Adam Neuwirth
  • 529
  • 5
  • 10