DOM Methods Flashcards

(13 cards)

1
Q

getElementById

A

Returns the element that has the ID attribute with the specified value

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

getElementsByClassName

A

Returns an array-like object (live HTMLCollection) of all child elements which have all of the given class name(s)

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

getElementsByTagName

A

Returns a live HTMLCollection of elements with the given tag name that are descendants of the specified element (could be document or specific element)

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

querySelector

A

Returns the first element within the document that matches the specified selector or group of selectors. If not found, returns null.

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

querySelectorAll(“”)

A

Returns a static NodeList representing a list of the document’s elements that match the specified group of selectors

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

If you access elements using ____, the returned list is live and will update as more elements are added to the node.

A

getElementsByTagName, getElementsByClassName

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

If you access elements using ____, the returned list is static and will NOT update if more elements are added to the node.

A

querySelector

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

:scope

A

Represents elements that are a reference point for selectors to match against

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

querySelectorAll(“:scope .outer .inner”)

A

“<div class=”“outer””>
<div class=”“select””>
<div class=”“inner””></div>
</div>
</div>”

By default, querySelectorAll() only verifies that the last element in the selector is within the search scope.

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

console.dir()

A

Displays an interactive list of properties of the specified JavaScript object

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

innerText

A

Gets or sets the XML or HTML markup contained within the element

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

Ex.
const name = “<img></img>”;
element.innerHTML = name;
// shows the alert

A

Providing an invalid <img></img> value will allow scripts in user-supplied data to run

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

insertAdjacentHTML

A

Inserts the HTML into the document rather than replacing the contents of an element

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