How to use Document writeln in JavaScript
This article describe about Document writeln() Method in JavaScript.
Document writeln() Method
It is different from write() method, writeln() method writes text with the newline after each statement.
Syntax
document.writeln(exp1,exp2,exp3,...)
|
Parameter |
Description |
(exp1,exp2,exp3,...) |
Optional. What to write to the output stream. Multiple arguments can be listed and they will be appended to the document in order of occurrence |
Example
<!DOCTYPE html>
<html>
<body>
<p>Note that write() does NOT add a new line after each statement:</p>
<pre>
<script type="text/javascript">
document.write("Hello friends!");
document.write("Have a good day!");
</script>
</pre>
<p>Note that writeln() add a new line after each statement:</p>
<pre>
<script type="text/javascript">
document.writeln("Hello friends");
document.writeln("Have a good day!");
</script>
</pre>
</body>
</html>
|
Output
You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here