document.write () and its output content style, position control _javascript skills
Source: Internet
Author: User
JS in one of the most basic commands: document.write (), for simple print content to the page, you can print verbatim text you need--document.write ("content"), where content is to be output Of course, there is a situation, need to output JS such as variables and so on change things, then need to use document.write (+variable), of course variable is the variable you want to output.
Now that you can output variables, you will definitely want to control the display of the variables, such as location and style. The first method of control is to apply an internal method of adding styles, such as
document.write ("<font style>=font-size:20px;font-family= Helvetica;" Content "</font>" in this way, but if the inside need to add too many styles, then not only appears bloated, but also not easy to modify.
In this case you definitely feel better with the selector. However, because of the use of the selector to use a variety of double quotes single quotes, so you should pay attention to prevent the use of double quotes and single quotes early match, I avoid the method is to use the \ "to remind the browser not to match prematurely, examples are as follows:
Here defines an ID selector named OK to control the style, because the ID name needs to be enclosed in double quotes, so in order to avoid matching the preceding double quotes, use \ "To declare it, and then in the CSS file
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