Javascript examples for DOM:Document createTextNode
Create text node with createTextNode() and set it to span
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w.j a v a 2 s .co m*/ var td1 = document.getElementById('Fruit'), text = document.createTextNode("Apple"); td1.replaceChild(text,td1.firstChild); } </script> </head> <body> <span id="Fruit">Banana</span> </body> </html>