Get HTML Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:HTML


The HTML object represents an HTML <html> element.

You can access the <html> element by using getElementsByTagName():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">get the HTML content of the html element</button>

<p id="demo"></p>

function myFunction() {//from   w  ww.j a  va 2s . co m
    var x = document.getElementsByTagName("HTML")[0].innerHTML;
    document.getElementById("demo").innerHTML = x;


Related Tutorials