DOM: More Methods Flashcards

1
Q

parentElement

A

Returns the DOM node parent element, or null if it has no parent or is not a DOM element

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

element.children

A

Returns a live HTMLCollection which contains all the child elements of the specified element

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

element.firstElementChild

A

Returns the first element within the specified element

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

element.previousElementSibling

A

Returns the element immediately preceding the specified one in the parent’s children list

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

element.nextElementSibling

A

Returns the element immediately following the specified one in the parent’s children list

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

element.nextElementSibling

A

Returns the element immediately following the specified one in the parent’s children list

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

element.childNode

A

Returns a live NodeList of child nodes of the given element where the first child node is assigned index 0. Child nodes include elements, texts, and comments.

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

element.firstChild

A

Returns the node’s first child in the tree, or null if the node has no children

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

element.firstChild.nodeValue

A

Returns the node’s value
In this example, it returns the node value of first child node on the specified element

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

element.previousSibling

A

Returns the node immediately preceding the specified one in the parent’s childNodes list, or null if the specified node is the first in the list

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

element.nextSibling

A

Returns the node immediately following the specified one in the parent’s childNodes list, or null if the node is the last in that list

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

document.createElement

A

Creates an element on the document

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

document.createTextNode

A

Creates a text node. Can be used to escape HTML character

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

element.appendChild( child) // no quotes

A

Adds a child node to the DOM

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

element.removeChild( child) // no quotes

A

Removes the child node from the DOM and returns the removed node

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

getAttribute

A

Returns the value of a specified attribute on the elements

16
Q

setAttribute

A

Sets the value of a specified attribute on the element

17
Q

element.classList

A

Returns a live DOMTokenList of class attributes of the specified element

18
Q

element.classList.add()

A

Adds the given tokens to the list omitting any that are already present

19
Q

element.classList.remove()

A

Removes the given tokens to the list