Javascript examples for DOM:Element replaceChild
Replace text in an HTML element using replaceChild method
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// w w w. ja v a2s .c om var td1 = document.getElementById('Fruit'), text = document.createTextNode("Apple"); td1.replaceChild(text,td1.firstChild); } </script> </head> <body> <span id="Fruit">Banana</span> </body> </html>