"JavaScript" Easily changes the color of the page background and font

Source: Internet
Author: User

JavaScript, by clicking on the button to change the page background and font color, the page has n change the color of the button, click on different buttons, the page font and background will be changed to different colors. Very simple JavaScript applet.

I. BASIC OBJECTIVES


Open a webpage first prompt greeting message "Hello"


There are n buttons in the page that change color, which returns the default color of the page, the background is white, the font is black

By clicking on a different button, the font and background of the page will change to different colors.

Originally wanted to make a rainbow improvement, but the principle is exactly the same as not much write button.


Second, the basic idea

The key is to provide ID to the body tag and the font JS, so that it is controlled in JS. This example provides an application to the JS function.


Third, the production process

For a simple small page, see the Notes for details:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The OnUnload () function is almost only valid when IE closes this page, and the dialog is not at the forefront, and Google Chrome has no effect. Therefore, this function has little meaning.


"JavaScript" Easily changes the color of the page background and font

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.