Event Target

Page section: playground
More on target

Fish list

Click on any on the following and check the console logs.

mackeral
flounder
halibut

waiting..

This was done with the following code:

const fishlist = document.getElementById('fish');

fishlist.addEventListener('click', (event) => {
    console.log(event.target.textContent)
    fishParagraph.textContent = event.target.textContent;
});

This can also be applied to the whole page. Press and then click on any page element and check the console.

Clicking the button runs the following:

let activate = () => {
    document.body.addEventListener('click', (event) => {
    console.log(event.target);
    });
};