How can I check if the user clicks any element on the screen in JS? I then want to be able to get the ID of that element in the process.
document.addEventListener("click", (event) => {
console.log(event.target.id);
// Do some stuff with the ID maybe
});
1 Like