按钮改变颜色:
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title></title> | |
| <script> | |
| function changeColor(str){ | |
| var body=document.getElementById("f"); | |
| body.style.backgroundColor=str; | |
| } | |
| </script> | |
| </head> | |
| <body id="f"> | |
| <button onclick="changeColor('blue')">蓝色</button> | |
| <button onclick="changeColor('green')">绿色</button> | |
| <button onclick="changeColor('red')">红色</button> | |
| </body> | |
| </html> | |
版权声明:本文为qq_40401942原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。