The Page and the DOM
Learn the HTML and CSS a JavaScript developer needs (no other course required), then meet the DOM: the page as the browser holds it. Find elements, change their text and classes, and add and remove elements while the page is open.
Updated
The HTML and CSS JavaScript Needs
- The HTML You Need for JavaScript (Novice): Read a web page the way JavaScript sees it, as elements with tags, attributes and content nested inside each other, with an id or a class on the ones your code needs to find.
- The CSS You Need for JavaScript (Novice): Read a CSS rule's selector, properties and values, pick elements by tag name, class, id or what they're inside, and see how a class added or removed by JavaScript changes the way an element looks.
The DOM in JavaScript
- Introducing the DOM: an overview (Novice): When the browser loads a page, it turns the HTML into the DOM, a tree of objects with one for each element, and JavaScript reads and changes the page through that tree.
- Locating DOM elements (Apprentice): Most searches start at the document, the whole page, where getElementById finds an element by its id, querySelector finds the first match for a CSS selector, and querySelectorAll finds every match.
Changing the Page
- Common DOM Interactions (Apprentice): Once you have an element, you change its text with textContent, its HTML with innerHTML, its look with style, and its CSS classes with classList.
- Manipulating the DOM Structure (Apprentice): createElement makes a new element, appendChild puts it inside a parent so it shows on the page, and remove takes an element off the page.
Exercise: Band Fan Page
- Exercise: Band Fan Page (Apprentice): Put a band's tour on its fan page with JavaScript, building a line for each upcoming show from an array, marking the sold-out ones and counting what's left, with tests for the data and a checklist for the page.