You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
444 B
JavaScript

//const body = document.body;
function findAncestor(el, cls){
while ((el = el.parentElement) && !el.classList.contains(cls));
return el;
}
// Event delegation. Body click, then check for buttons
body.addEventListener('click', (e) => {
if(e.target.classList.contains('button-close')){
let alertD = findAncestor(e.target, 'alert--dismissable');
if (typeof(alertD) != 'undefined' && alertD != null){
alertD.remove();
}
}
});