Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery for one page site

Tags:

jquery

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);
    }
});
like image 814
user2298099 Avatar asked Feb 16 '23 17:02

user2298099


1 Answers

It's because you're giving autofocus to your form fields which makes your fields automatically get focus when the page loads.

like image 145
Eli Avatar answered May 01 '23 13:05

Eli