1.3.6 - Getting and Setting Attribute Node Values Flashcards
.attributes, .getAttribute, .setAttribute are properties to work with nodes of type element?
YES
It is true that .attributes returns a live collection of all attribute nodes in the specific node?
YES

.attributes returns what?
a live collection of all attributes nodes in the specific node

.attributes returns a live collection of all attribute nodes…
That collection is a Array or a NamedNodeMap?
It´s a collection of NamedNodeMap, so it has´nt Array methods
What does this?

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
It is true that .getAttribute(attributeName) returns the value of a specified attribute on the element?
YES
.getAttribute() how many parameters needs?
One
.getAttribute(attributeName)
When using .getAttribute(attributeName) if the given value does not exist, the value returned will be…
either null or ”” (empty string)
How can we check if an attributeName exist prior to calling .getAttribute(attributeName)
We can use .hasAttribute(attName)
.hasAttribute(attName) returns true or false
What does .getAttribute(attName)?
returns the value of a specified attribute on the element. If the attName does not exist, returns null or “” empty string

How can we get the Attributes of an element?
Using
.attributes or .getAttribute(attName)
It is true that .setAttribute(name, value) adds a new attribute or change the value of an existing attribute on the specified element.
YES

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

.setAttribute(name, value)
.className what it does?
gets and sets the value of the class attribute of the specified element
var cName = elementNodeReference.className; elementNodeReference.className = cName;

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

What does .classList?
is a read-only property which returns a live collection of the class attributes of the element
.classList has methods?
name the most important methods of .classList
YES
.classList.add( string [,string] )
.classList.remove( string [,string] )
.classList.toggle( string [,force] )
.classList.contains( string )
.classList.add( string [,string] ) What it does?
If the classes already exist in the attribute of the element, then they are ignored, either case it adds it.

.classList.remove( string [,string] ) What it does?
Remove the specified class values

.classList.toggle( string [,force] )
Toggle the class value
// add or remove visible, depending on test conditional, i less than 10 div.classList.toggle(“visible”, i < 10 );
.classList.toggle( string [,force] ) What happens when a second argument is present?
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 );
.classList.contains( String ) what it does?
checks if speified class value exist in class attribute of the element.
alert(div.classList.contains(“foo”));
How can we get and set the class name attribute?
For getting the class name:
.className
.getAttribute( ‘class’ )
For setting the class name:
.setAttribute( ‘class’, value )
elementNodeReference.className = cName;
.classList.add( string [,string] )
When working with data properties, what can we use?
.dataset - it gives access to all data properties
