29 lines
605 B
JavaScript
Raw Permalink Normal View History

2025-04-15 21:48:37 -05:00
/*
Nicola Clark
15APR25
Adapted from https://javascript30.com - Sorting band names without articles
*/
const divs = document.querySelectorAll('div');
const btn = document.querySelector('button');
/**
* @param {MouseEvent} evt Click event
* @this HTMLElement
*/
function logText(evt) {
console.log(this.classList.value);
//console.log(this);
//evt.stopPropagation(); // <- event shouldn't bubble up!
}
divs.forEach((div) =>
div.addEventListener('click', logText, { capture: false, once: true }),
);
btn.addEventListener('click', () => console.log('button clicked!!!'), {
once: true,
});