I am trying to use JavaScript to get a clicked element\'s information.
Here is the jsFiddle.
And below is my code.
Probably best to attach the event listener to each of the p elements in case you have other children elements nested within the p element itself.
const paragraphs = document.querySelectorAll("div > p");
for (let i = 0; i < paragraphs.length; i += 1) {
paragraphs[i].addEventListener("click", function (event) {
console.log(event.currentTarget);
});
}