Check when any element is click on the screen in JavaScript

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