jQuery Smooth Scrolling

// target all links inside a container
$('#container a').on('click', function(){
	// store href attribute of the target in a variable
	var linkId = $(this).attr('href');
	// apply animate method to the body
	$('body').animate({
		// scroll to the top offset of the target
		scrollTop: $(linkId).offset.top
	}, 'slow');
	// prevent default click behaviour
	return false;
});

Comments are closed.