Fix toggle color schema button on desktop

This commit is contained in:
prototypa
2022-08-19 13:19:15 -04:00
parent 01801b9884
commit 577eb96663
2 changed files with 15 additions and 10 deletions

View File

@ -14,15 +14,20 @@ const {} = Astro.props;
}
function attachEvent(selector, event, fn) {
const elem = document.querySelector(selector);
if (elem) {
elem.addEventListener(
event,
function () {
fn(elem);
},
false
);
const matches = document.querySelectorAll(selector);
console.log(matches);
if (matches && matches.length) {
console.log("Hello");
matches.forEach((elem) => {
console.log(elem);
elem.addEventListener(
event,
function () {
fn(elem);
},
false
);
});
}
}