1、创建一个名称为hasAttributes 的html文件 ,并在body中加入一个onclick属性
2、添加一个button按钮,在点击事件中加入自定义函数myhasAttributes
3、添加一p标签,设置id 为 showhattributes
4、创建一个自定义函数 myhasAttributes
5、在自定义函数中获取对象,在用hasAttributes方法来判断该body对象中是否拥任何属性,将结果显示到p标签中
6、在浏览器中打开文件,点击button查看效果
时间:2024-12-01 10:03:51
1、创建一个名称为hasAttributes 的html文件 ,并在body中加入一个onclick属性
2、添加一个button按钮,在点击事件中加入自定义函数myhasAttributes
3、添加一p标签,设置id 为 showhattributes
4、创建一个自定义函数 myhasAttributes
5、在自定义函数中获取对象,在用hasAttributes方法来判断该body对象中是否拥任何属性,将结果显示到p标签中
6、在浏览器中打开文件,点击button查看效果