javascript - Efficient way of scrolling to part of page with jquery links -


i've asked in regards scroll identifier , have code working perfectly:

http://codepen.io/vsync/pen/kgcoa

however, wondering how can when click links on black scrollbar can scroll part of page. think along these lines:

$(".a1").click(function() {     $('html, body').animate({         scrolltop: $("#a1").offset().top     }, 2000); }); 

the scroll identification bit of javascript has been refined hoping there elegant , optimised way make can skip bits of page too.

any appreciated.

try this.

$("nav span").click(function() {     var sectionid = $(this).attr('class')     $('html, body').animate({         scrolltop: $('#'+sectionid).offset().top     }, 2000); }); 

fiddle demo


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -