I have created Alerts using Redux actions and they are generated whenever a post is successfully submitted or an error is generated. The problem is when the Alert is generated, it shows at the Top of the webpage, below the Navbar. So if the Alert is generated after clicking a button way below the top area, the Alert does not show because its displayed below the Navbar.
I want to make it so that whenever an Alert is displayed, it automatically scrolls up to the top of the webpage so the user can see it. Is it possible with simple css, bootstrap?
what you are looking for should be
window.scrollTo(0, 0);
first 0 represents the width, second height; to the top means 0, 0
check here https://www.w3schools.com/jsref/met_win_scrollto.asp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.