Answers for "scroll to top once clicked javascript html"

1

javascript scroll to top onclick

window.scroll({top: 0, left: 0});
//Or with jQuery
$('html,body').scrollTop(0);
//with animation
$('html, body').animate({ scrollTop: 0 }, 'fast');
Posted by: Guest on September-11-2020
0

javascript scroll to top onclick

//EITHER:

window.scroll({
 top: 0, 
 left: 0, 
 behavior: 'smooth' 
});

//OR:

window.scroll({top: 0, left: 0});
//Or with jQuery
$('html,body').scrollTop(0);
//with animation
$('html, body').animate({ scrollTop: 0 }, 'fast');
Posted by: Guest on February-05-2021

Code answers related to "scroll to top once clicked javascript html"

Code answers related to "Javascript"

Browse Popular Code Answers by Language