Define your var length external (up to) .each()
Using the .lentgh method, you can skip the indexes of the real page. Therefore, I would suggest capturing the real href s anchor.
FIDDLE DEMO
var pages = []; // skipping the "Next" and "Last" get all A ahchors $('div.pagination li').slice(0,-2).find('a').each(function(){ pages.push( $(this).attr('href') ); }); $.each(pages, function(i, v){ $('<div>'+ ("http://someWebsite.com"+v) +'</div>').appendTo('#output'); }); /* WILL RESULT IN: http://someWebsite.com/auctions/index/page:2 http://someWebsite.com/auctions/index/page:3 http://someWebsite.com/auctions/index/page:4 */
source share