js method document.write (); Used to output content to a browser page
Specific usage:
Used to output string content: document.write ("use double quotes for output string contents");
The value used to output the variable: such as var mynum= "Hello"; document.write (Mynum);
Used to output HTML tag content: such as document.write ("<p> Hello!</p>");
Used to output mixed content, use the "+" sign to connect content: such as document.write (mynum+ "<br/>" + "World");
------------------**********************************----------------------------------
How to use document.write () to output spaces to the browser:
Browser display mechanism, for manual typing of spaces, will be a number of consecutive spaces to display 1 spaces.
such as document.write ("1 2 3");
Output results: 1 2 3
Workaround:
1. Use HTML space tags to solve
such as document.write (" " + "+" + " " + "34");
Output results: 12 34
2. Use CSS styles to resolve
Add "WHITE-SPACE:PRE;" at output The Style property. This style means "blank space will be reserved by the browser";
Such as:
document.write ("<span style= ' white-space:pre; > "+" 1 4 "+" </span> ");
Output results: 1 23 4
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JS Learning Note (1) document.write () Method Usage Summary