mirror of
https://github.com/asimonson1125/asimonson1125.github.io.git
synced 2026-02-25 05:09:49 -06:00
Create checkbox filtering
This commit is contained in:
21
src/scripts/checkbox.js
Normal file
21
src/scripts/checkbox.js
Normal file
@@ -0,0 +1,21 @@
|
||||
export function toggle() {
|
||||
let toggles = document.querySelectorAll(
|
||||
".checkbox-wrapper input[type=checkbox]"
|
||||
);
|
||||
let allow = [];
|
||||
toggles.forEach(function (x) {
|
||||
if (x.checked) {
|
||||
allow.push(x.id);
|
||||
}
|
||||
});
|
||||
let list = document.querySelectorAll(".checkbox-client > div");
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
list[i].classList.add("hidden");
|
||||
for (let x = 0; x < list[i].classList.length; x++) {
|
||||
if (allow.includes(list[i].classList[x])) {
|
||||
list[i].classList.remove("hidden");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user