Get element by id and change the innerHTML : innerHTML : DOM Node JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » DOM Node » innerHTML »

 

Get element by id and change the innerHTML

















<html>
<head>
<script language="JavaScript" type = "text/javascript">
<!--
function ChangeText()
{
    var curtextval = document.getElementById("ptext");
    curtextval.innerHTML = "New Paragraph 1"
}
//-->
</script>
</head>
<body>
<form>
<p id="ptext">This is the first paragraph</p>
<P>This is the second paragraph</p>
  <input type="button" value="Click to Change Text" onClick="ChangeText()"></p>
</form>
</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo DOM Node
» innerHTML