I want to get certain elements from an xml file but need to increment them on each request. I have this code but need to increment "'site:eq(0),site:eq(1),site:eq(2)'". So when I next click the more button it will load "'site:eq(3),site:eq(4),site:eq(5)'" $("#more").click(function(){
$.ajax({
type: "GET",
url: "sites.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('site:eq(0),site:eq(1),site:eq(2)').each(function(){
var id = $(this).attr('id');
var title = $(this).find('title').text();
var url = $(this).find('url').text();
$('<div class="items" id="link_'+id+'"></div>').html('<a href="'+url+'">'+title+'</a>').appendTo('#page-wrap');
$(this).find('desc').each(function(){
var brief = $开发者_运维百科(this).find('brief').text();
var long = $(this).find('long').text();
$('<div class="brief"></div>').html(brief).appendTo('#link_'+id);
$('<div class="long"></div>').html(long).appendTo('#link_'+id);
});
});
}
});
});
Thanks for any help in solving this
Store the start-index in a variable(e.g. "start") and use this variable inside the selector:
'site:eq('+(start+0)'),site:eq('+(start+1)'),site:eq('+(start+2)')'
精彩评论