案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<input type="button" value="OK">
6
7
<p id="demo">点击按钮来删除 input 元素的 type 属性。</p>
8
9
<button onclick="myFunction()">试一下</button>
10
11
<script>
12
function myFunction()
13
{
14
var btn=document.getElementsByTagName("INPUT")[0];
15
btn.attributes.removeNamedItem("type");
16
}
17
</script>
18
19
<p><b>注释:</b>当删除 input 元素的 type 属性后,此元素的类型将是 <em>text</em>,即默认值。</p>
20
21
<p><b>注释:</b>在 Internet Explorer 8 以及更早的版本中,removedNamedItem 不会返回属性。</p>
22
23
</body>
24
</html>
25