given this html
<header>
<h1 id="title">Triathlon</h1>
</header>
<section id="sports">
<p class="swim">Swim</p>
<p id="bike">Bike</p>
<p>Run</p>
<h3> js output follows ******* </h3>
</section>
// these don’t work
swim.firstChild; undefined
swim.parentNode; undefined
swim.nextSibling; undefined
swimTextNode = swim.firstChild; undefined
swimTextNode.nodeValue; can’t read undefined
swim.textContent; undefined
swim.getAttribute(“class”); not a function
according to the book I’m reading “Javascript Novice to Ninja” swim( which is a class name) should work as well as bike ( an id name) but the id name works anc the class name doesn’t. I think this is probably an error on the authors part. What’s even stranger is that the last paragraph
Run
which has no id or class can be accessed with run, run isn’t listed in the code the text of the paragraph is of course Run with uppercase R yet if I enter “run.firstChild” or “run.textContent” it treats run as a legitimate identifier.