From the course: JavaScript: Enhancing the DOM (2013)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Targeting node elements
From the course: JavaScript: Enhancing the DOM (2013)
Targeting node elements
In the last movie, we talked about basic access properties for node elements and the problem with traversing the DOM nodes using child nodes. Sometimes you get text elements that are just carriage returns. Some browsers support a better way of selecting elements. So, for example, you can use the property called first element child, and that gives you the first child only if it's an element. Like a tag. So, it would ignore any comment or text nodes. You can also use, of course, last element child and children. Which gives you only children that are elements. Of course, you can also use previous element sibling and next element sibling that's the equivalent of the previous sibling and next sibling. Now, before you get too excited about this, this has really lousy browser support. So, if you go to this page and you take a look at this right here, it's showing you that its available in IE 9 but not in some versions of Firefox. So, it's something good to use for newer browser support but…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Selecting elements with getElementById4m 10s
-
(Locked)
Choosing elements by HTML tag3m 20s
-
(Locked)
Isolating elements by class name3m 12s
-
(Locked)
Querying CSS to select elements4m 54s
-
(Locked)
Working with named form elements3m 39s
-
(Locked)
Understanding nodeType, nodeName, and nodeValue4m 30s
-
(Locked)
Traversing up and down DOM nodes4m 40s
-
(Locked)
Targeting node elements2m 44s
-
(Locked)
-
-
-
-