javascript中如何使用setAttributeNode方法?

时间:2026-02-15 15:34:47

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

javascript中如何使用setAttributeNode方法?

2、添加一个h1 元素,设置一个样式类设置字体大小和颜色

javascript中如何使用setAttributeNode方法?

3、添加一个button按钮,在点击事件中加入自定义函数  mysetAttributeNode

添加一p标签,设置id 为 showsetAttributeNode

javascript中如何使用setAttributeNode方法?

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

javascript中如何使用setAttributeNode方法?

5、在自定义函数中获取h1元素对象,创建一个节点属性 class,并设置节点的内容为myclass,h1元素对象添加节点属性

javascript中如何使用setAttributeNode方法?

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

javascript中如何使用setAttributeNode方法?

javascript中如何使用setAttributeNode方法?

© 2026 途途旅游
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com