The Thinking Behind Simplifying Event Handlers

1 · CSS-Tricks · May 9, 2019, 2:24 p.m.
Events are used to respond when a user clicks somewhere, focuses on a link with their keyboard, and changes the text in a form. When I first started learning JavaScript, I wrote complicated event listeners. More recently, I've learned how to reduce both the amount of code I write and the number of listeners I need. Let’s start with a simple example: a few draggable boxes. We want to show the user which colored box they dragged. <section> <div id="red" … Read article The post The Thinking Be...