I am trying to use JavaScript to get a clicked element's information.
Here is the jsFiddle.
And 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?
Answer: event.target
Thanks Juan Mendes