87,996
社区成员




if(node.hasChildNodes()){JavaScript code goes here......}
if(node.childNodes.length!=0){JavaScript code goes here......}
if(node.getAttribute("name")){JavaScript code goes here......}
if(node.getAttribute("name")!=null){JavaScript code goes here......}
if(node.attributes("name")!=null){JavaScript code goes here......}
if(node.hasAttribute("name")){JavaScript code goes here......}
if(node.attributes().getNamedItem("name").value){JavaScript code goes here......}
<div style="width:200px;height:200px;background-color:red;" onclick="if(this.hasChildNodes()){alert('Yes');} else alert('No');">
</div>
<div style="width:200px;height:200px;background-color:green;" onclick="if(this.childNodes.length!=0){alert('Yes');} else alert('No');">
</div>
node.hasAttribute("attName");//,not work in IE6,IE7