<html> <body> <script language="JavaScript"> function function1() { var m = document.createTextNode("This is the text."); var n = myP.firstChild.replaceNode(m); m.deleteData(5, 10); } </script> <p id="myP">Sample text.</p> <input type="button" value="Remove data" onclick="function1();"> </body> </html>