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

mod rewrite - Using "?" when rewriting the URL -

.htaccess: Transfer name to index.php if not directory public -

Admob integration with pygame in android -