prep-javascript-dom manipulation-dom events-dom creation Flashcards

1
Q

What is the DOM?

A

The DOM is the Document Object Model; and it is what is created by the browser when loading a web page.

It is a model of the HTML document and all of its parts recreated as JavaScript objects.
It is not the HTML document itself, but a recreation of it in a form that JavaScript can understand and influence.

The DOM is a W3C standard. The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document.

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

What does document.querySelector() return?

A

document.querySelector() returns the first element that matches the specified selector or group of selectors.

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

How do you modify the text of elements on the DOM?

A

Using the following syntax:

[element].textContent = ‘New text’;

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

What arguments does the addEventListener method take?

A

event, function, and useCapture

useCapture is optional. It is a boolean (true or false) that specifies if the event should be executed in the capturing phase or the bubbling phase (default).

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

Give five examples of JavaScript events that can be listened for.

A
  1. click
  2. mouse over
  3. mouse out
  4. change
  5. drag
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does document.createElement() take as its argument?

A

tagName, which specifies the type of element to be created
and
options, which creates a ElementCreationOptions object

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

What does document.createElement() return?

A

The new Element, specifically the Javascript object representing the HTML element.

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

How do you append elements to the DOM?

A

Using the appendChild() method

ex: document.body.appendChild(p);
ex2: $parent.appendChild($child);

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