[英]jQuery and XML: Is this the last element?
I have grabbed some XML
data using this piece of jQuery: 我使用这个jQuery抓取了一些
XML
数据:
$.ajax({
type: "POST",
url: "siteList.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('wrapper').each(function(){
$(this).find('site').each(function(){
//check whether this is the last element...
});
});
}
});
What I would like to do is: Check whether I am parsing the last site
element from the XML
I pulled in. 我想做的是:检查我是否正在解析我引入的
XML
的最后一个site
元素。
edit: I cannot (as far as I'm aware), do this: 编辑:我不能(据我所知),这样做:
$(this).find('site').each(function(){
$(this).last(); //nope
$(this).find('site').last(); //nope
});
Just use something like this to get the last site: 只需使用这样的东西来获取最后一个网站:
$(this).find('site').last()
Hope it helps! 希望能帮助到你!
Take a look at the ':last' selector or the .last() function. 看看':last'选择器或.last()函数。 You could do a test to see if the current site is the same as the last one.
您可以进行测试以查看当前站点是否与上一站点相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.