29 lines
605 B
JavaScript
29 lines
605 B
JavaScript
/*
|
|
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,
|
|
});
|