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
Copy Code code as follows:
document.write ("<font size=" +0 ">=font-size:20px;font-family= Helvetica;" Content "</font>"
There are too many styles to add, so it is not only 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:
document.write ("<div id=\" Ok\ ">" +percentage+ "</div>");
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
You can define the style and position you want.
The above mentioned is the entire content of this article, I hope you can enjoy.