Mega Code Archive

 
Categories / JavaScript Tutorial / DOM Node
 

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>