I’m using this code to scroll to specific areas of my website.
What function should I add to this code to scroll to specific div when entering website?
$(window).load(function(){
function goToByScroll(id){
// Remove "link" from the ID
id = id.replace("link", "");
// Scroll
$('html,body').animate({
scrollLeft: $("#"+id).offset().left},
'slow');
}
$("#index > a").click(function(e) {
// Prevent a page reload when a link is pressed
e.preventDefault();
// Call the scroll function
goToByScroll($(this).attr("id"));
});
});
Try this :-
see this examlple http://jsfiddle.net/VPzxG/1141/