Home > Web Front-end > JS Tutorial > What is the usage of document in js? Detailed explanation of document color attribute in js

What is the usage of document in js? Detailed explanation of document color attribute in js

云罗郡主
Release: 2018-11-08 14:02:05
Original
6483 people have browsed it

In js, many people don’t know what attributes are used to set the color in the web page. Different sections use different color attributes. The document object is actually used to set the color in the web page. Let’s summarize it below. What is the usage of document in js.

1: The document object represents the color attribute

1. Define the current document color: fgColor

2. Define the background color of html: bgcolor

3. Define the color of the hyperlink. The hyperlink is the link that has not been visited: linkColor

4. Define the color of the hyperlink. The hyperlink is the activated link: alinkColor

5. Define the color of the hyperlink. The hyperlink is the visited link: vlinkColor

2: Detailed explanation of the document color attribute in js

1. Background color and Detailed explanation of the properties of the foreground color

In js, many people use document to set the foreground color and background color, but there are also many people who do not distinguish between the foreground color and the background color. In fact, the foreground color is the color of the text. , the background color refers to the background color of the web page.

The syntax of background color and foreground color:

document.bgColor = "Color value";

document.fgColor = "Color value";

The color value here can be in English or hexadecimal.

For example:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        document.fgColor = "white";
        document.bgColor = "red";
    </script>
</head>
<body>
    <div>php中文网</div>
</body>
</html>
Copy after login

is displayed as follows:

What is the usage of document in js? Detailed explanation of document color attribute in js

2. Hyperlink color attribute

In js, use linkColor Wait for some attributes to represent the hyperlink color attribute. The syntax is:

document.linkColor = "color value";

Code example:

        document.vlinkColor = "blue";
Copy after login

The above is the description of document in js What is the usage? A complete introduction to the detailed explanation of the document color attribute in js. If you want to know more about JavaScript tutorial, please pay attention to the php Chinese website.


The above is the detailed content of What is the usage of document in js? Detailed explanation of document color attribute in js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template