Intermediate JavaScript Flashcards
What is The Document Object Model?
A way to manipulate the structure and style of an HTML page. It represents the internals of the page as the browser sees it, and allows the developer to alter it with JavaScript.
HTML is an ______ structure in that the elements form a structure of parents’ nodes with children, like the branches of a tree.
XML-like
The DOM is also called?
The DOM tree
What is the root element of the DOM tree?
html
To access the DOM from JavaScript, the _______ object is used.
document
The document objects is provided by the _______ and allows code on the page to interact with the content.
browser
How do you get an element by its id?
document.getElementById
getElementById is a method of the document object
Example: var pageHeader = document.getElementById('page-header');
What are the ways to retrieve an element?
- ) ID – getElementById
- ) Tag name – getElementsByTagName
- ) Class name – getElementsByClassName
- ) CSS selector – querySelector or querySelectorAll
What is a NodeList?
An array of DOM Elements
What’s the difference between querySelector and querySelectorAll
querySelector, like getElementById, returns only one element whereas querySelectorAll returns a NodeList
What happens if multiple elements match the selector you pass to querySelector?
If multiple elements match the selector you pass to querySelector, only the first will be returned.
What is event-driven programming?
Writing interactive applications in JavaScript is often about waiting for and reacting to events, to alter the behavior of the browser in some way.
To react to an event you listen for it and supply a function which will be called by the browser when the event occurs. This function is known as a ________.
Callback
What is needed to listen for an event?
- ) The callback function
- ) An element
- ) The call to listen for an event
________ is a method found on all DOM elements used to add an event to listen for.
addEventListener
Developers got more ambitious with the web, attempting to build interactive applications sometimes called _______.
“native-like”
________ is a way to load new content into a page without a full reload.
AJAX
What does AJAX stand for?
Asynchronous JavaScript and XML
What is the underlying tech used to create AJAX pages?
XML HTTP Request (XHR)
Who originally created XMLHttpRequest?
Microsoft developing Outlook Web Access