标签:style width height class java strong css span size
1 通过元素的style属性
//html <div id="box"></div> //js var box = document.getElementById(‘box‘); box.style.width = ‘100px‘; box.style.height = ‘100px‘; box.style.backgroundColor = ‘red‘; <div id="box" style="width:100px; height:100px; background-color:red">
2 通过元素的className属性
//html <div id="box"></div> //css .show{ width:100px; height:100px: background-color:red; } //js var box = document.getElementById(‘box‘); box.className = ‘show‘;
javascript教程系列40:DOM中操作样式的两种方式
标签:style width height class java strong css span size
原文地址:https://www.cnblogs.com/autoXingJY/p/9007425.html