改变CSS样式
1.改变HTML元素样式的语法
//改变HTML样式的语法 document.getElementById(id).style.property = new style
例子:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>change CSS</title> </head> <body> <h1 id="demo">样式变化</h1> <button type="button" onclick="change()">点我改变内容样式</button> <script> function change(){ document.getElementById('demo').style.color='red'; } </script> </body> </html>