Get Div Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div


The Div object represents an HTML <div> element.

You can access a <div> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<div id="myDIV">This is a div element.</div>

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

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

function myFunction() {/*from ww 2 s . c o m*/
    var x = document.getElementById("myDIV").innerHTML;
    document.getElementById("demo").innerHTML = x;


Related Tutorials