🤯 New: Coding Assessments Practice your skills on real-world programming challenges

jQuery AutoScroll to Div (specific page element)

Sam Deering
Share

jQuery code snippet to autoScroll to a div or any page element with an id. Just change the jQuery selector “mydiv” with whatever element id you wish.

function scroll_to(div){
	$('html, body').animate({
		scrollTop: $("mydiv").offset().top
	},1000);
}