Remove the type attribute from an input button:
const nodeMap = document.getElementById("myInput").attributes;
nodeMap.removeNamedItem("type");
Try it Yourself »
Note: When removing the type attribute of an input element, the element will be of type text, which is the default value.
The removeNamedItem()
method removes a node (by name) in a NamedNodeMap.
namednodemap.removeNamedItem(
nodename)
Parameter | Description |
nodename | Required. The name of the attribute node to remove |
Type | Description |
A node | The removed attribute node. |
attributes.removeNamedItem()
is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!