12 lines
365 B
JavaScript
12 lines
365 B
JavaScript
|
const articles = document.getElementsByTagName("article");
|
||
|
|
||
|
document.getElementById("filter").classList.remove("hidden");
|
||
|
|
||
|
function filter(e) {
|
||
|
for (const a of articles)
|
||
|
a.classList.toggle("hidden",
|
||
|
!(e.target.name === "all" || a.id.startsWith(e.target.name)));
|
||
|
}
|
||
|
|
||
|
for (const b of document.getElementsByTagName("button"))
|
||
|
b.addEventListener("click", filter);
|