如果在文档中设置了属性值,则 specified 属性返回 true,如果是 DTD/Schema 中的默认值,则返回 false。
浏览器兼容性:
所有主要浏览器都支持 specified 属性
attribute.specified
返回值: | Boolean, true|false |
---|---|
DOM 版本 | Core Level 1 |
检查属性是否有指定的值:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Web176教程(web176.com)</title> </head> <body> <p id="demo">单击按钮查找按钮是否有onclick属性</p> <button >