एक्सएमएल डोम में चाइल्डनोड्स () विधि है
नोड वस्तु
उदाहरण
निम्न कोड खंड " books.xml " को xmlDoc में लोड करता है और देता है कि पहले <book> तत्व में कोई चाइल्ड नोड है या नहीं:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
var xmlDoc = xml.responseXML;
var x =
xmlDoc.getElementsByTagName('book')[0];
document.getElementById("demo").innerHTML =
x.hasChildNodes();
}
उपरोक्त कोड का आउटपुट होगा:
true
परिभाषा और उपयोग
यदि निर्दिष्ट नोड में कोई चाइल्ड नोड है, तो hasChildNodes () विधि सही है, अन्यथा गलत है ।
ब्राउज़र समर्थन
hasChildNodes() विधि सभी प्रमुख ब्राउज़रों में समर्थित है।
वाक्य - विन्यास
nodeObject.hasChildNodes()
मापदंडों
कोई नहीं।
प्रतिलाभ की मात्रा
Type | Description |
---|---|
Boolean | Returns true if the specified node has any child nodes, otherwise false |
टेक्निकल डिटेल
डोम संस्करण | कोर स्तर 1 नोड वस्तु |
---|
नोड वस्तु