Differences between document. write and writeln output content

Source: Internet
Author: User

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]

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.