获取节点
改变节点样式
<script> // 第一步 获取节点 var fa = document.querySelector(".fa"); console.log(fa); // 更改节点样式 fa.style.height = "100px"; fa.style.width = "200px"; fa.style.backgroundColor = "red"; // 获取一个节点属性getAttribute console.log( fa.getAttribute("data-id")); // 获取所有的属性attributes console.log( fa.attributes); // 更改属性setAttribute("属性","值") fa.setAttribute("data-id","2") console.log(fa); </script>