Get element by id and change the innerHTML : innerHTML « DOM Node « JavaScript Tutorial





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










23.11.innerHTML
23.11.1.Get element by id and change the innerHTML
23.11.2.Change hyperlink innerHTML
23.11.3.Change InnerHTML
23.11.4.innerHTML of body element