Cheatsheet Format: Web
JavaScript DOM Cheatsheet
The selectors, traversal methods, events and mutation APIs you actually use, on one printable page.
Abhishek Sharma 2026-08-06 Programming / JavaScript
Selecting elements
document.querySelector('.card');
document.querySelectorAll('[data-role="tab"]');
element.closest('.card');
element.matches('.is-active');
Creating and inserting
const item = document.createElement('li');
item.textContent = 'New item';
list.append(item);
Events
button.addEventListener('click', (event) => {
event.preventDefault();
console.log(event.currentTarget);
});
Use event delegation for lists that change frequently.
Want more like this?
Browse every cheatsheets in the library, organised by topic.
Related learning
Tutorial
An Introduction to JavaScript
Learn what JavaScript is, its history, and how to get started with tools and the developer console
Programming / JavaScript
JavaScriptProgramming
Tutorial
JavaScript Fundamentals
Master the basics: Hello World, code structure, variables, data types, and type conversions
Programming / JavaScript
JavaScriptProgramming
Tutorial
Operators, Comparisons, Conditionals, and Loops
Master JavaScript operators, comparisons, conditional branching, logical operators, and loops
Programming / JavaScript
JavaScriptOperators