Handling events in the browser is a pretty common task with many nuances. Getting it right can save you a lot of frustration and make the user experience much more enjoyable. This collection will help you get started with event handling using JavaScript.
Adds an event listener to an element with the ability to use event delegation.
JavaScript, Browser · Oct 21, 2020
Removes an event listener from an element.
JavaScript, Browser · Oct 21, 2020
Adds an event listener to an element that will only run the callback the first time the event is triggered.
JavaScript, Browser · Oct 22, 2020
Runs the callback whenever the user clicks outside of the specified element.
JavaScript, Browser · Jan 6, 2021
Understand how events work in JavaScript and learn when to use event bubbling, event capturing and event delegation with this short guide.
JavaScript, Browser · Jun 12, 2021
Attaches an event listener to all the provided targets.
JavaScript, Browser · Apr 22, 2021
Detaches an event listener from all the provided targets.
JavaScript, Browser · Apr 22, 2021
Adds multiple event listeners with the same handler to an element.
JavaScript, Browser · Oct 22, 2020
Learn how to attach an event handler to events that is executed at most once in this JavaScript article.
JavaScript, Browser · Jun 12, 2021
Scroll listeners can easily become a performance bottleneck for your web application. Here's how to fix that.
JavaScript, Browser · Mar 7, 2023
Runs the callback whenever the user has stopped scrolling.
JavaScript, Browser · Jan 6, 2021
Learn the differences between JavaScript ES6 arrow functions and regular functions and how they affect event listener callbacks.
JavaScript, Browser · Jun 12, 2021
If you need to check if Caps Lock is on when the user is typing in the browser, JavaScript's got you covered.
JavaScript, Browser · Jun 12, 2021
Triggers a specific event on a given element, optionally passing custom data.
JavaScript, Browser · Oct 22, 2020
Runs the callback whenever the user input type changes (mouse
or touch
).
JavaScript, Browser · Oct 21, 2020