Javascript DOM HTML Paragraph 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   ww  w . j  a  v  a2 s . c o  m

</body>
</html>



PreviousNext

Related