Home › Forums › JavaScript › jQuery Array › Re: jQuery Array
October 26, 2012 at 7:03 am
#112723
Taufik Nurrohman
Participant
// Get the current page url:
var currentUrl = window.location.href;
var currLink = $('#tracks').find('a[href="' + currentUrl + '"]');
// Get the index:
var index = curLink.parent().index() + 1; // (+1) means 'next'
// Get the next `li > a` href:
var nextPage = currLink.parent().next().find('a').attr('href');
// Show the index & the href value:
$('.nav').append(index + ': ' + nextPage);