DOMおれおれAdvent Calendar 2015 – 07日目 jQueryだと属性の操作はほとんど attr() で済むんですが、DOMは色々setとgetと分かれてます。あと名前が長いです。 // el = <a href="#top">TOP</a> console.log(el.getAttribute('href')); // => "#top" el.setAttribute('href', '#top-of-the-world'); console.log(el.getAttribute('href')); // => "#top-of-the-world"
![属性の操作はsetAttribute()とかremoveAttribute()とか、あとattributesで。(DOMおれおれAdvent Calendar 2015 – 07日目) | Ginpen.com](https://cdn-ak-scissors.b.st-hatena.com/image/square/de4af7f62b39439905833504e59ba1e153be6d8b/height=288;version=1;width=512/https%3A%2F%2Fginpen.com%2Fwp-content%2Fthemes%2Fginpen-theme%2Fimg%2Ficon-512.png)