𝗠𝗘𝗥𝗡 𝗦𝗧𝗔𝗖𝗞: 𝗗𝗔𝗬 𝟮𝟮
I spent Day 22 learning JavaScript events.
Events make your webpage interactive. An event is a signal. It happens when a user clicks a button or types in a field.
I learned two ways to handle these signals.
Inline triggers in HTML. This mixes logic with structure. It makes code messy. Avoid this method.
Event functions in a script file. Select the element. Assign a function to it. This is the professional standard.
Example: let btn = document.querySelector("#myBtn"); btn.onclick = () => { console.log("Button clicked"); };
Source: https://dev.to/ali_hamza_589ec7b3eb6688d/22-day-of-learning-mern-stack-2eb4