prep-javascript-dom manipulation-dom events-dom creation Flashcards
What is the DOM?
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.
What does document.querySelector() return?
document.querySelector() returns the first element that matches the specified selector or group of selectors.
How do you modify the text of elements on the DOM?
Using the following syntax:
[element].textContent = ‘New text’;
What arguments does the addEventListener method take?
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).
Give five examples of JavaScript events that can be listened for.
- click
- mouse over
- mouse out
- change
- drag
What does document.createElement() take as its argument?
tagName, which specifies the type of element to be created
and
options, which creates a ElementCreationOptions object
What does document.createElement() return?
The new Element, specifically the Javascript object representing the HTML element.
How do you append elements to the DOM?
Using the appendChild() method
ex: document.body.appendChild(p);
ex2: $parent.appendChild($child);