Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery Array Re: jQuery Array

#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);