Javascript DOM HTML Div Object set inner html

Introduction

Change the HTML content of two elements:

View in separate window

<!DOCTYPE html>
<html>
<body>

<h1>My Web Page</h1>

<p id="myP">This is a p element.</p>

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

<script>
document.getElementById("myP").innerHTML = "Hello Dolly.";
document.getElementById("myDIV").innerHTML = "How are you?";
</script>/*from w  ww  . ja  v  a2s .  c o m*/

</body>
</html>



PreviousNext

Related