<style>
.hidden {
display: none!important;
}
</style>
<script>
function setViewAll() {
let lists = document.querySelectorAll('.post-cards-toggle');
let buttons = document.querySelectorAll('.tab_content_button');
// Set Hide
lists.forEach((list, index) => {
const posts = list.querySelectorAll('.post-card');
const qtyToShow = 2;
posts.forEach((post, index) => {
if (index >= qtyToShow) {
post.classList.add('hidden');
}
});
if (qtyToShow >= posts.length) {
buttons[index].classList.add('hidden');
}
});
// BTN Click
buttons.forEach((button, index) => {
button.addEventListener('click', function() {
const postsToShow = lists[index].querySelectorAll('.post-card');
postsToShow.forEach(post => {
post.classList.remove('hidden');
});
button.classList.add('hidden');
});
});
}
document.addEventListener('DOMContentLoaded', function() {
setViewAll();
});
</script>