JavaScript? CSS ???? ???? ?????.
??:
nodeObject.style.cssProperty=newStyle
??? nodeObject? ?? ???? cssProperty? CSS ???? newStyle? CSS ??? ????.
??: "-"? ??? CSS ??? ?? "-"? ???? "-" ?? ? ?? ??? ???? ?????.
?:
document.getElementById("demo").style.height = "50px" ; document.getElementById("demo").style.border = " 1px solid #ddd "; document.getElementById("demo").style.backgroundColor = " #ccc "; document.getElementById("demo").style.textAlign = " center ";
?: id="demo"? ?? ???? ?????.
<style> #demo{ height:50px; width:250px; margin-top:10px; text-align:center; line-height:50px; background-color:#ccc; } </style> <div id="demo"> 點擊這里改變CSS樣式 </div> <script type="text/javascript"> document.getElementById("demo").onclick=function(){ this.style.height = " 70px "; this.style.lineHeight = " 70px "; this.style.backgroundColor = " #000 "; this.style.color=" #fff "; } </script>