From the course: JavaScript: Enhancing the DOM

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Understanding nodeType, nodeName, and nodeValue

Understanding nodeType, nodeName, and nodeValue

From the course: JavaScript: Enhancing the DOM

Start my 1-month free trial

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…

Contents