HTML DOM removeAttributeNode() နည်းလမ်း
❮ Element Objectဥပမာ
class attribute node ကို <h1> ဒြပ်စင်တစ်ခုမှ ဖယ်ရှားပါ-
var elmnt = document.getElementsByTagName("H1")[0]; // Get the first <h1> element in the document
var attr = elmnt.getAttributeNode("class"); // Get the class attribute node from <h1>
elmnt.removeAttributeNode(attr); // Remove the class attribute node from <h1>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
removeAttributeNode() method သည် သတ်မှတ်ထားသော attribute ကို element တစ်ခုမှ ဖယ်ရှားပြီး Attr Node object တစ်ခုအနေဖြင့် ဖယ်ရှားထားသော attribute ကို ပြန်ပေးသည် ။
ဤနည်းလမ်းနှင့် removeAttribute() နည်းလမ်းကြား ခြားနားချက်မှာ removeAttribute() နည်းလမ်းသည် သတ်မှတ်ထားသော အမည်ဖြင့် အရည်အချင်းကို ဖယ်ရှားခြင်းဖြစ်ပြီး ၊ ဤနည်းလမ်းသည် သတ်မှတ်ထားသော Attr အရာဝတ္တု ကို ဖယ်ရှားနေချိန်တွင် ဖြစ်သည်။ ရလဒ်ကတော့ အတူတူပါပဲ။ ထို့အပြင် removeAttribute() method တွင် return value မရှိပါ ။ Attr object တစ်ခုအနေဖြင့် ဤနည်းလမ်းသည် ဖယ်ရှားထားသော attribute ကို ပြန်ပေးပါသည်။
အကြံပြုချက်- ဒြပ်စင်တစ်ခု၏ attribute node တစ်ခုကို ပြန်ပေးရန်အတွက် getAttributeNode() နည်းလမ်းကို အသုံးပြု ပါ ။
အကြံပြုချက်- ဒြပ်စင်တစ်ခုသို့ attribute node တစ်ခုထည့်ရန် setAttributeNode() နည်းလမ်းကို အသုံးပြု ပါ။
Browser ပံ့ပိုးမှု
Method | |||||
---|---|---|---|---|---|
removeAttributeNode() | Yes | Yes | Yes | Yes | Yes |
အထားအသို
element.removeAttributeNode(attributenode)
ကန့်သတ်တန်ဖိုးများ
Parameter | Type | Description |
---|---|---|
attributenode | Attr object | Required. The attribute node you want to remove |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ဖယ်ရှားလိုက်သော attribute node ကိုကိုယ်စားပြုသည့် Attr အရာ |
---|---|
DOM ဗားရှင်း | Core Level 1 Element Object |
နောက်ထပ် ဥပမာများ
ဥပမာ
href attribute node ကို <a> element တစ်ခုမှ ဖယ်ရှားပါ-
var elmnt = document.getElementById("myAnchor"); // Get the <a> element with id="myAnchor"
var attr = elmnt.getAttributeNode("href"); // Get the href attribute node from <a>
elmnt.removeAttributeNode(attr); // Remove the href attribute node from <a>
ဆက်စပ်စာမျက်နှာများ
HTML သင်ခန်းစာ- HTML အရည်အချင်းများ
HTML DOM ရည်ညွှန်း- HTML DOM ရည်ညွှန်းချက် အရာဝတ္တု
HTML DOM အကိုးအကား- removeAttribute() နည်းလမ်း
HTML DOM အကိုးအကား- getAttributeNode() နည်းလမ်း
HTML DOM ရည်ညွှန်းချက်- setAttributeNode() နည်းလမ်း
❮ Element Object