HTML DOM removeAttribute() 方法
定义和用法
removeAttribute() 方法从元素中删除指定的属性。
此方法与 removeAttributeNode() 方法的区别在于,removeAttributeNode()方法删除指定的Attr对象, 而此方法删除具有指定名称的属性。结果是一样的。此外,该方法没有返回值,而removeAttributeNode()方法将删除的属性作为Attr对象返回。
提示: 使用 getAttribute() 方法返回元素属性的值。
提示: 使用 setAttribute() 方法向元素添加属性。
浏览器支持
| 方法 | |||||
|---|---|---|---|---|---|
| removeAttribute() | Yes | Yes | Yes | Yes | Yes | 
语法
element.removeAttribute(attributename)
参数值
| 参数 | 类型 | 描述 | 
|---|---|---|
| attributename | String | 必需。要删除的属性的名称 | 
技术细节
| 返回值: | 无返回值 | 
|---|---|
| DOM 版本 | Core Level 1 Element Object | 
更多实例
相关页面
HTML 教程: HTML 属性
HTML DOM 参考手册: hasAttribute() 方法
HTML DOM 参考手册: getAttribute() 方法
HTML DOM 参考手册: setAttribute() 方法
