Jump to content

HTML DOM/Javascript help


BooKwiznak

Recommended Posts

Hello forum,Not sure if this is the right place to ask this question, but I was going through the HTML DOM tutorials and came on a 'road block'. I'm in the Node Access section and the last example where they mention using the firstChild property is confusing me a bit. The following example code is :

<html><body><p id="intro">Hello World!</p><script type="text/javascript">x=document.getElementById("intro");document.write(x.firstChild.nodeValue);</script></body></html>

And the output would be: Hello World!Now here is my code:

<html><body><p>Hello World!</p><p>Bye World!</p><script type="text/javascript">x=document.getElementsByTagName("p");document.write(x.lastChild.nodeValue);</script></body></html>

I'm trying to get the output to be: Bye World! The code doesn't work. Am I missing something?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...