Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
110
rated 0 times [  114] [ 4]  / answers: 1 / hits: 16750  / 13 Years ago, wed, october 19, 2011, 12:00:00

I wanted to ask how to change div content, but not using innerhtml.


More From » dom

 Answers
62

You can use nodeValue to access the value of a node, however the value of a div. In your example you might have the following HTML...



<div id=myLovelyDiv>This is the text that you want to change</div>


and this script...



var myDiv = getElementById(myLovelyDiv);
myDiv.childNodes[0].nodeValue = The text has been changed.;


but I fail to see why you wouldn't use



myDiv.innerHTML = The text has been changed properly.;

[#89531] Tuesday, October 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devonw

Total Points: 311
Total Questions: 116
Total Answers: 111

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;