JavaScript DOM Customization Cheat Sheet
JavaScript DOM Customization Cheat Sheet
Quick reference for DOM navigation, responsiveness, buttons, and animations.
1. DOM Selection & Manipulation
- getElementById, querySelector, createElement
- innerHTML, setAttribute, classList, style
2. Navigation & Menus
- Toggle mobile menu using [Link]()
- Scroll-based nav highlighting
3. Responsiveness
- [Link], resize listener
- Adjust layout dynamically
4. Buttons & Interactivity
- Click, hover, dblclick listeners
- Loading animation on button
5. Animations
- CSS + JS toggling (fade-in)
- JS-based movement (requestAnimationFrame)
- Smooth scrolling to anchors
6. Utilities
- Dark mode toggle with localStorage
- Collapse nav on link click
- Fade-in on scroll
Tips:
- Use requestAnimationFrame for smooth animations
- Debounce scroll/resize
- Prefer toggling classes to inline styles
- Respect prefers-reduced-motion