jquery - One page prev/next navigation based on list/anchor links -


after finished laughing @ attempt modify jquery me with:

http://goo.gl/mnhqq8

what happen is:

to left 2 visible buttons prev/next hide other li's. prev button work , go previous anchor , next going next anchor.

or going wrong way... open better suggestions.

thanks

only modified few parts:

first, keep 2 buttons:

<li><a href="#prev" class="scroll">prev</a></li> <li><a href="#next" class="scroll">next</a></li> 

next, keep track of different anchors, , 1 active:

var anchors = ['anchortop', 'anchorone', 'anchortwo', 'anchorthree', 'anchorfour', 'anchorfive']; var currentidx = 0; 

finally, either decrement or increment currentidx depending on button clicked , section at:

var full_url = this.href,     parts = full_url.split('#'),     btn = parts[1];  if (btn == 'prev' && currentidx > 0) {     currentidx--; } else if (btn == 'next' && currentidx < anchors.length - 1) {     currentidx++; }  var trgt = anchors[currentidx],     target_offset = $('#' + trgt).offset(),     target_top = target_offset.top; 

fiddle


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -