<body>
<input type="button" value="zj" οnclick="tj();" class="testbutton" id = "b01">
<script type="text/javascript">
var s = document.getElementById("b01");
//获取属性
var s1= s.getAttribute("class");//testbutton
//设置属性
s.setAttribute("class","csbutton");
// alert(s.getAttribute("class"));//csbutton
//删除属性
s.removeAttribute("class");
// alert(s.getAttribute("class"));//null
s.removeAttribute("value");
alert(s.getAttribute("value"));//null IE zj 非IE不兼容
</script>
</body>
getAttribute setAttribute removeAttribute
最新推荐文章于 2021-06-01 17:30:29 发布