function checkRoot(element) { var nodes = element.getElementsByTagName('*'), hasChild = []; for (var i = 0; i < nodes.length; i++) { if (nodes[i].childNodes.length > 0) { hasChild.push(nodes[i]); } } return hasChild; }