This article is a small web page production skill using JS. It is used in many places. It can change the color of HTML pages through JS. If you are interested, learn it.
Let’s take a look at the specific demonstration renderings first
The following is the complete HTML page code, you can test it.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> .big_box{ width: 500px; height: 500px; border: 1px solid black; } .big_box input{ margin-left: 60px; } </style> <script> function Change_red(){ var Red=document.getElementById("change_style"); Red.style.backgroundColor="red"; } function Change_blue(){ var Blue=document.getElementById("change_style"); Blue.style.backgroundColor="blue"; } function Change_green(){ var Green=document.getElementById("change_style"); Green.style.backgroundColor="green"; } </script> </head> <body> <p class="big_box" id="change_style"> <input type="button" value="变为红色" onclick="Change_red()"> <input type="button" value="变为蓝色" onclick="Change_blue()"> <input type="button" value="变为绿色" onclick="Change_green()"> </p> </body> </html>
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to use ngrok express to solve WeChat interface debugging problems
How to use element-ui tables to make cells editable
How to use vue-cli to write a vue plug-in
The above is the detailed content of How to change page color in JS (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!