Targeting the attributes property


show more Targeting the attributes property provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the JavaScript: Enhancing the DOM show less
please wait ...

Targeting the attributes property

Another way you can get access to attributes inside your nodes is through the attributes property. Once you retrieve this property, its values can be accessed in a number of ways. So you can look for them by numeric index, also by named index or dot notation. So, let's take a look at how that works. So here's my file, I'm going to get into the console, and I'll create a variable that accesses a specific node instance.

Let's test my node, and it has the first image, and that is this image right here. So, we can get to all the attributes inside this image by using my node and then type in attributes. When we hit Enter, you see that we have a node map, and it's a list of all the attributes in numeric order. Now this is a pretty interesting object, because it has attributes of both array elements, and also objects. So, you can get to the source attribute in a number of ways. It's the first attribute, so it would have an index of zero. And that works...

Targeting the attributes property
Video duration: 1m 24s 2h 3m Intermediate

Viewers:

Targeting the attributes property provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the JavaScript: Enhancing the DOM

Subjects:
Developer Web
Software:
HTML JavaScript
Author:
please wait ...