[JavaScript] easily changes the webpage background and font color, and the javascript webpage background
JavaScript: click the button to change the color of the background and font of the webpage. There are N buttons for changing the color of the webpage. Click different buttons to change the font and background of the webpage to different colors. Simple JavaScript applet.
I. Basic Objectives
When you open the webpage, the system first prompts "hello"
There are N buttons in the webpage that change the color. The returned result is the default color of the webpage, the background is white, and the font is black.
Click different buttons to change the font and background of the webpage to different colors.
I wanted to make a rainbow, but I didn't need to write more buttons in the same principle.
Ii. Basic Ideas
The key is to provide an id for the body label and the font js to control it in js. This example provides applications for js functions.
Iii. Production Process
For details on a simple small page, see the notes:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The onunload () function is only valid when IE closes this page, and this dialog box is not at the frontend. Google Chrome does not have any effect. Therefore, this function is of little significance.
How does javascript change the text background color?
Try the following ..
<P id = "pTag"> This is the text in p </p>
Document. getElementById ("pTag"). style. backgroundColor = "red"
How does javascript change the background color?
You want:
Function border1 (color1 ){
$ ("Border1"). style. border = "1px solid #" + color1;
$ ("Border1"). style. borderTop = "5px solid #" + color1;
// Body background color:
Document. bgColor = "#" + color1;
}
In addition:. style. border = "1px solid #" + color1; it seems that the pixels, styles, and colors cannot be set. Of course, I have not read this carefully. You can use it on your own.