Assignments > Tutorial 5: JavaScript: Event Handlers
Due Mon, 02/23 at 11:59pm
Overview
This tutorial series focuses on DOM manipulation: selecting elements, changing classes, and updating behavior when users click buttons.
1. Download Starter Files
After downloading and unzipping, move the tutorials folder into your csci344/tutorials folder.
2. Complete the 4 parts of the Tutorial
You will complete Tutorial 5 in four short parts:
- Tutorial 5A: Theme Switcher (starter code provided)
- Tutorial 5B: Hamburger Menu (build from scratch)
- Tutorial 5C: Carousel (starter code provided)
- Tutorial 5D: Todo List (build from scratch)
Please see the JavaScript Cheatsheet for syntax help and examples.
What to Submit
After completing all four sub-tutorials (5A, 5B, 5C, and 5D), please:
- Create links from your homepage to each Tutorial 5 page.
- Commit and push your changes to GitHub.
- Submit both:
- your GitHub repository link
- your GitHub Pages link
If you collaborated with someone, include your partner’s name in your submission comments.
Summary of JavaScript DOM Functions Used
Here’s a summary of the JavaScript DOM methods and techniques used across all four tutorials:
Method / Property Tutorial Purpose & Example document.querySelector()5A, 5B, 5D Select a single element by CSS selector document.querySelector('#nav-links')document.querySelectorAll()5C Select multiple elements by CSS selector document.querySelectorAll('.carousel-item')element.classList.add()5A Add one or more classes element.classList.add('active')element.classList.remove()5A Remove one or more classes element.classList.remove('active')element.classList.toggle()5A, 5B Toggle a class (add if missing, remove if present) element.classList.toggle('active')element.classList.contains()5A Check if element has a class element.classList.contains('active')element.classList.replace()5A Replace one class with another element.classList.replace('old', 'new')element.value5D Get or set the value of an input element input.valueorinput.value = ''element.insertAdjacentHTML()5D Insert HTML at a specific position list.insertAdjacentHTML('beforeend', '<li>Item</li>')element.style.transform5C Set CSS transform property item.style.transform = 'translateX(-400px)'onclickattribute5A, 5B, 5D Attach click event handler in HTML <button onclick="functionName()">