DOM对象 怎么使用 removeattribute方法

2025-04-15 14:58:41

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方法
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢