HTML DOM Element removeAttributeNode() စနစ်
- 上一页 removeAttribute()
- 下一页 removeChild()
- 返回上一层 HTML DOM Elements အကို
အသုံးပြုခြင်း နှင့် လက်ဆုံး
removeAttributeNode()
အရာ ဖျက်သိမ်း လုပ်ကိုင် ပြီး ပြန်လည် ပေးသည် Attribute အရာ
removeAttribute() နှင့် removeAttributeNode() အကြား ကွဲပြားခြင်း
removeAttribute()
စနစ် ဖျက်သိမ်း လုပ်ကိုင် ပြီး အပြန် သတင်း မပြန်လည်ပေးသည်
removeAttributeNode()
စနစ် ဖျက်သိမ်း Attr အရာထွက်ပြီး ဖြတ်ကျော်သွားသော အရာ ကို ပြန်လည်ပေးသည်
ရလဒ် အတူတူပါ
အခြား ပြောင်းလဲခြင်း
အသုံးပြုခြင်း removeAttribute() 方法 ပိုမို လက်ရှိနိုင်
တခုခု ကို ကျွန်းပြီ
လုပ်သုံးခြင်း စာရင်း
教程:
实例
例子 1
从第一个
元素中删除 class 属性节点:
const element = document.getElementsByTagName("H1")[0];
const attr = element.getAttributeNode("class");
element.removeAttributeNode(attr);
例子 2
从链接中删除 href 属性节点:
const element = document.getElementById("myAnchor"); const attr = element.getAttributeNode("href"); element.removeAttributeNode(attr);
语法
element.removeAttributeNode(oldAttr)
参数
参数 | 描述 |
---|---|
oldAttr | 必需。要删除的属性节点。 |
返回值
类型 | 描述 |
---|---|
对象 | 表示已删除属性的 Attr 对象。 |
抛出
异常 | 描述 |
---|---|
NO_MODIFICATION_ALLOWED_ERR | 当前元素是只读的,不允许删除属性。 |
NOT_FOUND_ERR | oldAttr 不是当前元素的属性。 |
说明
该方法将从当前元素的属性集合中删除(并返回)Attr 节点。如果 DTD 给删除的属性设置了默认值,那么该方法将添加一个新的 Attr 节点,表示这个默认值。
提示:用 removeAttribute() 方法 代替该方法往往会更简单。
浏览器支持
element.removeAttributeNode()
是 DOM Level 1 (1998) 特性。
所有浏览器都完全支持它:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
支持 | 9-11 | 支持 | 支持 | 支持 | 支持 |
- 上一页 removeAttribute()
- 下一页 removeChild()
- 返回上一层 HTML DOM Elements အကို