Document. write () // write the content to the document. The current editing position is the last character of the written content.
Document. writeln () // write the content to the document and add a line break. The current editing position is the last line of the written content.
Document. write () and document. writeln is a method written by JavaScript to the client. writeln is output in line mode, but it does not refer to the line feed in the actual page effect. The two methods differ only when viewing the source code, unless it is output to the pre or xmp Element
Test:
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Run the above Code. In the new window: view-source file, you can see that writeln is output in line.
The difference between the actual effect is that the line feed in the source code will lead to a "space" in the actual effect to compare the following example:
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Input result: 111 222
Therefore, in applications, using write is more convenient than writeln and does not produce unnecessary space effects. Therefore, my Html and Js online conversion gadgets [Transform.
Test the retention format:
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]