getAttribute နည်းလမ်း
getAttribute နည်းလမ်းသည် တဂ်တစ်ခုမှ
သတ်မှတ်ထားသော Attribute ၏ တန်ဖိုးကို ဖတ်ရှုသည်။
ဝါကျဖွဲ့ပုံ
element.getAttribute(attribute အမည်);
ဥပမာ
အောက်ပါ element ၏ value
Attribute ပါ အကြောင်းအရာကို ထုတ်ပြကြပါစို့:
<input id="elem" value="abcde">
let elem = document.querySelector('#elem');
let value = elem.getAttribute('value');
console.log(value);
ကုဒ်ကို လုပ်ဆောင်ခြင်း၏ ရလဒ်:
'abcde'
ဒါတွေလည်း ကြည့်ပါ
-
setAttributeနည်းလမ်း,
သည် Attribute များကို ရေးသားသည့် နည်းလမ်း -
removeAttributeနည်းလမ်း,
သည် Attribute များကို ဖယ်ရှားသည့် နည်းလမ်း -
hasAttributeနည်းလမ်း,
သည် Attribute များကို စစ်ဆေးသည့် နည်းလမ်း