I know, this is really a noob question and I don't really know what went wrong.
The code is very simple. I have a web page that contains the following:
<div id="mydiv"> <p>first</p> </div>
The <p> tags are created by the following js code:
paragraph = document.createElement("p"); text = document.createTextNode("first"); paragraph.appendChild(text); document.getElementById('mydiv').appendChild(paragraph);
var mydiv = document.getElementById('mydiv'); var p = mydiv.childNodes; var text = p.childNodes; // I tried others like p.text alert(text.nodeValue);
I tried many other ways to get the text, but I just can't get it. Everytime I get null or blank or Object Text or no pop up at all. I am pretty sure document.getElementById('mydiv') is getting the right div. Can someone please give me an example, please, I feel so stupid because this shouldn't be a problem but I just can't really find a solution. Thank you so much!