javascript scroll to top
snippet in javascript

javascript go to top of page

user2622

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

javascript scroll to top

user3506

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
  document.body.scrollTop = 0; // For Safari
  document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}

scrool to top jquerry

user5265

$("a[href='#top']").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});

scroll to top

user8651

	$("#scroll_icon").click(function()
	{
		jQuery('html,body').animate({scrollTop:0},2000);
	})

js scroll to top

user9411

window.scrollTo(x-coord, y-coord);