How to append content the end of a HTML document

Append to the end

document.writeln() appends content to the end of the HTML document.

Example


<!DOCTYPE HTML> 
<html> 
    <body> 
        <p> 
            This is a test.<!--   w  w  w. ja  v a 2s . c o  m-->
        </p> 
        <script> 
              document.writeln("new added");
            
        </script> 
    </body> 
</html>

Click to view the demo

Output tags

The following code uses document.writeln() to append tags.


<!DOCTYPE HTML> 
<html> 
    <body> 
        <p id="myText"> 
            <span id="mySpan">HTML</span> 
            This is a test.<!--  www  .j  ava2s  . c om-->
            This is a test.
        </p> 

        <script> 
              document.writeln("<pre>J ava 2s .com</pre>");
            
        </script> 
    </body> 
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window