<html> <body> <script language="JavaScript"> function function1() { var myRange = document.selection.createRange(); var m = myRange.parentElement(); m.innerText = 'ParentElement'; } </script> <input id="myB" type="button" value="Click me" onclick="function1();"> </body> </html>