Reputation: 41
I am using following jquery code for my one page portfolio my site http://www.hettzdesigns.com
but when page loads it directly goes to contact section of site instead of index section.
Can anyone tell where it is going wrong.
$(document).ready(function(){
$('nav ul li a').click(function(){
var el = $(this).attr('href');
var elWrapped = $(el);
scrollToDiv(elWrapped,140);
return false;
});
function scrollToDiv(element,navheight){
var offset = element.offset();
var offsetTop = offset.top;
var totalScroll = offsetTop-navheight;
$('body,html').animate({
scrollTop: totalScroll
}, 650);
}
});
Upvotes: 4
Views: 170
Reputation: 14827
It's because you're giving autofocus
to your form fields which makes your fields automatically get focus when the page loads.
Upvotes: 8