次のうち、DOMで属性を表すノードはどれですか?
- Propertyノード
- Attributeノード
- Styleノード
- Eventノード
正解
- Attributeノード
解説
Attributeノードは要素の属性を表します。ただし、現在では属性操作はgetAttribute()などのメソッドを通じて行うことが一般的です。
使用例(サンプルコード)
[ javascript ]
let link = document.querySelector("a");
console.log(link.getAttribute("href"));