Javascript examples for DOM:Document writeln
The writeln() method outputs text to document with a newline character after each statement.
document.writeln(exp1, exp2, exp3, ...);
Parameter | Description |
---|---|
exp1, exp2, exp3, ... | Optional. arguments to be appended to the document in order of occurrence |
No return value
The following code shows the difference between write() and writeln():
<!DOCTYPE html> <html> <body> <p>Note that write() does NOT add a new line after each statement:</p> <pre> <script> document.write("Hello World!"); document.write("Have a nice day!"); </script>/*from w ww .ja v a2s . c om*/ </pre> <p>Note that writeln() add a new line after each statement:</p> <pre> <script> document.writeln("Hello World!"); document.writeln("Have a nice day!"); </script> </pre> </body> </html>