So I've this little code:
As far as I understand, the <p> inside the <div> should be its child, and in this case the first and last child. In that case, the script should alert "Hello" since it's the innerHTML of the <p> element.Code:<!DOCTYPE html> <html> <head> </head> <body> <div id="first"> <p>Hello</p> </div> <script> var x=document.getElementById("first"); alert(x.firstChild.innerHTML); </script> </body> </html>
Obviously I'm missing something and would love to be enlightened.
Thanks.


Reply With Quote
Bookmarks