Get Div Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Introduction

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>
<html>
<body>

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

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

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

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

</body>
</html>

Related Tutorials