aeq aeq - 1 year ago 159
jQuery Question

jquery check if xml element has children?

I know how to use JQuery to iterate over the children of an xml element:

$(this).children('tag_name').each(function() {


Is there a convenient way to simply test if an element has any children? Something like this incorrect code:

$(this).hasChildren('tag_name') //returns true or false

Answer Source

Use this method:

var hasChildren = $(this).children('tag_name').length > 0;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download