Is there a simple way to force the browser to scroll to the top if a button is clicked?
I have tried
jQuery('html').scrollTop();
jQuery('body').scrollTop();
jQuery(window).scrollTop();
None of them seem to scroll to the top of the page.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Due to cross browser oddness, some browsers will respond to
'html'and some to'body'. And maybe its just my luck, but.scrollTop(0)has never worked for me to move the page. Give this a shot:This version is tested and cross browser for all desktop browsers, and mobile devices.