我知道如何使用 JQuery 迭代 xml 元素的子元素:
$(this).children('tag_name').each(function() {
});
是否有一种方便的方法来简单地测试元素是否有子元素?像这样的错误代码:
$(this).hasChildren('tag_name') //returns true or false
最佳答案
使用此方法:
var hasChildren = $(this).children('tag_name').length > 0;
关于jquery 检查 xml 元素是否有子元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3550022/