<html> <body> <p id="myP" class="explanations">Sample text.</p> <script language="JavaScript"> function function1(){ var m = myP.firstChild.appendData(" This is the added string."); } </script> <input type="button" onClick="function1();" value="Append data"> </body> </html>