Member-only story
How to to check if a button is clicked in JavaScript
1 min readSep 30, 2022
#1. How to detect a button click
if(document.getElementById('button').clicked == true)
{
alert("button was clicked");
}
#2. How to check if you clicked something
Here we will have to add an event listener.
// get the element
const element = document.getElementById('profile_title')// always checking if the element is clicked, if so, do alert('hello')
element.addEventListener("click", () => {
alert('hello');
});
Amazon Links to “Must-Haves” as a WFH Software Engineer 🙂💻
24-inch budget-friendly monitor, Portable monitor, Laptop stand, Waterproof desk mat, Keyboard cleaning gel, Six-outlet wall charger and surge protector,, Wi-Fi extender, Blue-light–blocking glasses, Memory foam gel pad, Foam footrest
Courses to learn more about datastructures/algorithms ✍️
Courses to learn more about databases 👓
DB Foundations, Data Scientists specialization
Courses to learn more about React 🧢
Full-Stack WebDev, Front-End WebDev with React, IBM Full Stack