I am trying to use JavaScript to get a clicked element's information. Below is my code.
let div = document.querySelector('div') div.addEventListener('click', function(event) { // how to get the clicked p tag here? // this? // event.target.currentTarget? }) <div> <p>text 1</p> <p>text 2</p> </div> How can I use this to get the element's information?
event.target?event.targetwill give you the element that was clicked on whileevent.currentTargetwill give you the element the event was originally bound to (i.e. the div).