<div id="container">
<button>Click me!</button>
</div>
<pre id="output"></pre>
const output = document.querySelector("#output");
function handleClick(e) {
output.textContent += `You clicked on a ${e.currentTarget.tagName} element\n`;
}
const container = document.querySelector("#container");
container.addEventListener("click", handleClick);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.