getAttributeNode() 方法从当前元素中通过名称获取属性节点。
提示:如果你仅想返回属性值请使用 getAttribute 方法。
所有主要浏览器都支持 getAttributeNode() 方法
element.getAttributeNode(attributename)
参数 | 类型 | 描述 |
---|---|---|
attributename | String | 必须。你想返回的属性名。 |
类型 | 描述 |
---|---|
Attr object | 指定的属性节点 |
DOM 版本 | Core Level 1 Element Object |
---|
返回链接的 target 属性:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Web176教程网(web176.com)</title> </head> <body> 读取<a href="dom_obj_attributes.php" target="_blank">Attr 对象</a>. <p id="demo">单击按钮以显示上述链接的目标属性的值</p> <button >