javascript - How can I replace this text in an HTML element? -


i have string shows "banana"

i want replace "apple"

this have

<span id="fruit">banana</span> 

this script i'm using.

    var td1 = document.getelementbyid('fruit');     var text = document.createtextnode("apple");     td1.appendchild(text); 

and shows as.

bananaapple

    <span id="fruit">     "banana"     "apple"     </span> 

how can rid of banana , replace apple?

<span id="fruit">apple</span> 

just update innerhtml: http://jsfiddle.net/sntml/

document.getelementbyid('fruit').innerhtml = "apple"; 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -