1
<input type="button" value="OK">
2
<p id="demo">单击下面的按钮删除上面元素的属性类型。</p>
3
<button onclick="myFunction()">点我</button>
4
<script>
5
function myFunction() {
6
var btn = document.getElementsByTagName("INPUT")[0];
7
btn.attributes.removeNamedItem("type");
8
}
9
</script>
10
<p><strong>注意:</strong> 当删除一个输入元素的type属性,元素的类型将变成<em> text</em>,这是默认值。</p>
11
<p><strong>注意:</strong> In Internet Explorer 8 及更早的版本中,removedNamedItem也将返回属性值,但是不会移除属性。</p>