getAttribute setAttribute removeAttribute

来源:互联网 发布:php订餐系统源码 编辑:程序博客网 时间:2024/06/07 09:49
        <body>        <input type="button" value="zj" onclick="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>

原创粉丝点击