时间:2021-07-01 10:21:17 帮助过:5人阅读
document.getElementById(id).style.property=new style
<p id="p2">Hello World!</p>
<script>
document.getElementById("p2").style.color="blue";
</script>
JS改变元素属性;
代码如下:
<script>
var div = document.getElementByIdx_x('d1');
div.setAttribute("class", "abc");
</script>