The writeln()
method outputs content as the write()
method
and adds a newline character.
document.writeln(exp1,exp2,exp3,...)
Parameter | Description |
---|---|
exp1,exp2,exp3,... | Optional. What to write to the output stream. |
writeln |
Yes | Yes | Yes | Yes | Yes |
The following code shows how to use write() and writeln() methods.
<!DOCTYPE html>
<html>
<body>
<pre>
<script>
document.write("A");
document.write("B");
</script><!-- w w w . j ava2 s. c o m-->
</pre>
<pre>
<script>
document.writeln("C");
document.writeln("D");
</script>
</pre>
</body>
</html>
The code above is rendered as follows: