एक्सएमएल डोम में एट्रिब्यूट्स () विधि है
नोड वस्तु
उदाहरण
निम्न कोड खंड " 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.hasAttributes();
}
आउटपुट:
true
परिभाषा और उपयोग
यदि निर्दिष्ट नोड में कोई विशेषता है, अन्यथा गलत है, तो hasAttributes () विधि सही है ।
नोट: यदि निर्दिष्ट नोड एक तत्व नोड नहीं है, तो वापसी मान हमेशा गलत होता है ।
ब्राउज़र समर्थन
hasAttributes() विधि सभी प्रमुख ब्राउज़रों में समर्थित है।
नोट: Internet Explorer 9 और इससे पहले के संस्करण hasAttributes() पद्धति का समर्थन नहीं करते हैं।
वाक्य - विन्यास
nodeObject.hasAttributes()
मापदंडों
कोई नहीं।
प्रतिलाभ की मात्रा
Type | Description |
---|---|
Boolean | Returns true if the specified node has any attributes, otherwise false |
टेक्निकल डिटेल
डोम संस्करण | कोर लेवल 2 नोड ऑब्जेक्ट |
---|
नोड वस्तु