Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get id of current element clicked

//JavaScript
document.querySelectorAll('div').forEach((e) => {
  e.onclick = (e) => console.log(e.currentTarget.id);
});
Source by ebazhanov.github.io #
 
PREVIOUS NEXT
Tagged: #id #current #element #clicked
ADD COMMENT
Topic
Name
2+8 =