+ Start a Discussion

Auto scroll-down to bottom of the component

I have a lightning component in which there is a button which loads some new divs on click of the same button. What I want to implement is that it should auto scroll-down to the bottom of the page and should show those new divs itself(without scrolling the page). So that I don't have to manually scroll down to the bottom of the page.

Any help would be greatly appreciated! Thanks!
Sunil MadanaSunil Madana
1. If you are creating new divs with textinput or textbox, add focus() event listener to the textinput to automatically scroll the page to the newly created div.
2. You can also create the dynamic divs with id as '#1' or your favorite name and inside the javascript use like below:
window.location.hash = '#<<yourdivid>>';
Hope the above answer helps and please mark as correct answer so others can benefit from it.