I'm currently reading the "[u]Professional JavaScript for Web Developers</u>" book by Nicholas C Zakas. In page 171 he talks about how to access specific nodes (he is talking about the DOM) and he shows a way on how to get to them using the tag name. Anyway, this is the code that I'm having trouble with:
Code:
<html>
<head>
<title>DOM Example</title>
<script>
//<![CDATA[
var oPs = document.getElementsByTagName("p");
var oImgsInP = oPs[0].getElementsByTagName("img");
//]]>
</script>
</head>
<body>
<p style="color:red" id="p1">
<img src="images/donramon.jpg" name="something" />
</p>
<input type="button" value="show the tag" />
</body>
</html>
I keep getting the "oPs.1 is null or not an object" and I am copying the code exactly as it is in the book, can anyone help please?