Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

anchor tag and name attribute animated scroll

Tags:

jquery

menu

i have done this http://jsfiddle.net/thilakar/WsxJy/3/ using with anchor tag and name attributes.

but i need to do using with jquery like below link. http://www.jibevisuals.com/

when click on "about us" menu page moves slowly up. I need that kind of work.

Any suggestion

Thanks in advance.

like image 731
Mr.T.K Avatar asked Jan 04 '12 10:01

Mr.T.K


1 Answers

Description

You can do this using jQuery.offset() and jQuery.animate().

Check out the jsFiddle Demonstration.

Sample

function scrollToAnchor(aid){
    var aTag = $("a[name='"+ aid +"']");
    $('html,body').animate({scrollTop: aTag.offset().top},'slow');
}

scrollToAnchor('id3');

More Information

  • jsFiddle Demonstration
  • jQuery.offset()
  • jQuery.animate()
like image 95
dknaack Avatar answered Oct 01 '22 18:10

dknaack