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
Post a Comment