DOM对象 怎么使用 removeattribute方法

时间:2024-10-12 16:37:49

1、创建一个名称为 removeAttribute 的html文件

DOM对象 怎么使用 removeattribute方法

2、添加一个h1元素,并设置id和class,添加一个样式表设置样式类的颜色为红色

DOM对象 怎么使用 removeattribute方法

3、添加一个button按钮,在点击事件中加入自定义函数myremoveAttribute添加一p标签,设置id 为 showremoveAttribute

4、创建一个自定义函数 myremoveAttribute

DOM对象 怎么使用 removeattribute方法

5、在自定义函数中获取h1对象,用removeAttribute方法移除h1 中的class属性改变h1中字的颜色

DOM对象 怎么使用 removeattribute方法

6、在浏览器中打开文件,点击button查看效果

DOM对象 怎么使用 removeattribute方法
DOM对象 怎么使用 removeattribute方法
© 手抄报圈