XML DOM hasAttributes() နည်းလမ်း
❮ Node Object
ဥပမာ
အောက်ဖော်ပြပါ ကုဒ်အပိုင်းအစသည် " 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
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
သတ်မှတ်ထားသော node တွင် attribute တစ်ခုခုရှိလျှင် hasAttributes() method သည် true ပြန်ပေးသည်၊ သို့မဟုတ်ပါက false ဖြစ်သည် ။
မှတ်ချက်- သတ်မှတ်ထားသော node သည် Element node မဟုတ်ပါက၊ return value သည် အမြဲတမ်း false ဖြစ်သည်။
Browser ပံ့ပိုးမှု
hasAttributes() နည်းလမ်းကို အဓိက ဘရောက်ဆာအားလုံးတွင် ပံ့ပိုးထားသည်။
မှတ်ချက်- Internet Explorer 9 နှင့် အထက်တွင် hasAttributes() နည်းလမ်းကို မပံ့ပိုးပါ။
အထားအသို
nodeObject.hasAttributes()
ကန့်သတ်ချက်များ
တစ်ခုမှ
တန်ဖိုးကို ပြန်ပေးသည်။
Type | Description |
---|---|
Boolean | Returns true if the specified node has any attributes, otherwise false |
နည်းပညာဆိုင်ရာအသေးစိတ်
DOM ဗားရှင်း | Core Level 2 Node Object |
---|
❮ Node Object