Event Propagation
Bubbling Phase
const randomInt = (min, max) =>
Math.floor(Math.random() * (max - min + 1) + min);
const randomColor = () =>
`rgb(${randomInt(0, 255)}, ${randomInt(0, 255)}, ${randomInt(0, 255)})`;
document.querySelector('.nav__link').addEventListener('click', (e) => {
this.style.backgroundColor = randomColor();
});
document.querySelector('.nav__links').addEventListener('click', (e) => {
this.style.backgroundColor = randomColor();
});
document.querySelector('.nav').addEventListener('click', (e) => {
this.style.backgroundColor = randomColor();
});target und currentTarget
target und currentTargetPropagation stoppen
Capturing Phase
Last updated



