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

17 lines
542 B

function filterArticles() {
const tagSelect = document.getElementById('tag-select');
const selectedTag = tagSelect.value;
const articles = document.querySelectorAll('.article');
articles.forEach(article => {
const tags = article.getAttribute('data-tags').split(' ');
if (selectedTag === 'all' || tags.includes(selectedTag)) {
article.style.display = 'flex';
} else {
article.style.display = 'none';
}
});
}
// Initial call to display all articles
filterArticles();