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.
Understanding nodeType, nodeName, and nodeValue
From the course: JavaScript: Enhancing the DOM (2013)
Understanding nodeType, nodeName, and nodeValue
Every DOM element has a few important properties you can use to identify the node. So we're going to take a look at some of those properties in this movie. So, for example, the nodeType property gives you a numerical value of a node. The nodeName property gives you the name of the node, usually the tagName. So for example an anchor tag would have a type of A. Node.atrributes is a how you can access attributes inside a node. So if you were inside an anchor tag you could ask for a list of attributes and get the href attribute. Also the node value let's you access an element inside a node. So let's take a look at these in an actual document. So here we are in our sample file. I'm going to hit Cmd+Option+I, Ctrl+Alt+I on the PC and then hit the Esc key to pull up the console. So I'll start out by creating a variable called myNode, and then assigning it an element in our page. In this case, I'm going to choose the last link in our navigation menu, which is right here, so we'll type in…
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)
-
-
-
-