1.3.6 - Getting and Setting Attribute Node Values Flashcards

1
Q

.attributes, .getAttribute, .setAttribute are properties to work with nodes of type element?

A

YES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

It is true that .attributes returns a live collection of all attribute nodes in the specific node?

A

YES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

.attributes returns what?

A

a live collection of all attributes nodes in the specific node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

.attributes returns a live collection of all attribute nodes…

That collection is a Array or a NamedNodeMap?

A

It´s a collection of NamedNodeMap, so it has´nt Array methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does this?

A

We are returning all the attributes from the first link (a tag) in the document

We are using .nodeName and .nodeValue to console log the attribute name and the attribute value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

It is true that .getAttribute(attributeName) returns the value of a specified attribute on the element?

A

YES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

.getAttribute() how many parameters needs?

A

One

.getAttribute(attributeName)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When using .getAttribute(attributeName) if the given value does not exist, the value returned will be…

A

either null or ”” (empty string)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can we check if an attributeName exist prior to calling .getAttribute(attributeName)

A

We can use .hasAttribute(attName)

.hasAttribute(attName) returns true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does .getAttribute(attName)?

A

returns the value of a specified attribute on the element. If the attName does not exist, returns null or “” empty string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can we get the Attributes of an element?

A

Using

.attributes or .getAttribute(attName)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

It is true that .setAttribute(name, value) adds a new attribute or change the value of an existing attribute on the specified element.

A

YES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can we add or change an attribute on a specified element?

A

using

.setAttribute(name, value)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

.className what it does?

A

gets and sets the value of the class attribute of the specified element

var cName = elementNodeReference.className; elementNodeReference.className = cName;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

It is true that .classList is a read-only property which returns a live collection of the class attriutes of the element?

A

YES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does .classList?

A

is a read-only property which returns a live collection of the class attributes of the element

17
Q

.classList has methods?

name the most important methods of .classList

A

YES

.classList.add( string [,string] )

.classList.remove( string [,string] )

.classList.toggle( string [,force] )

.classList.contains( string )

18
Q

.classList.add( string [,string] ) What it does?

A

If the classes already exist in the attribute of the element, then they are ignored, either case it adds it.

19
Q

.classList.remove( string [,string] ) What it does?

A

Remove the specified class values

20
Q

.classList.toggle( string [,force] )

A

Toggle the class value

// add or remove visible, depending on test conditional, i less than 10 div.classList.toggle(“visible”, i < 10 );

21
Q

.classList.toggle( string [,force] ) What happens when a second argument is present?

A

If the second argument evaluates to true, it add the specified class value

If the second argument evaluates to false, it removes the specified class value.

// add or remove visible, depending on test conditional, i less than 10 div.classList.toggle(“visible”, i < 10 );

22
Q

.classList.contains( String ) what it does?

A

checks if speified class value exist in class attribute of the element.

alert(div.classList.contains(“foo”));

23
Q

How can we get and set the class name attribute?

A

For getting the class name:

.className

.getAttribute( ‘class’ )

For setting the class name:

.setAttribute( ‘class’, value )

elementNodeReference.className = cName;

.classList.add( string [,string] )

24
Q

When working with data properties, what can we use?

A

.dataset - it gives access to all data properties