-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
29 lines (27 loc) · 859 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function toggleMoreProducts() {
const products = document.querySelectorAll('.product-card');
const seeMoreButton = document.querySelector('.see-more');
let visibleCount = 0;
products.forEach((product) => {
if (product.style.display !== 'none') {
visibleCount++;
}
});
if (visibleCount === 6) {
// Show all products
products.forEach((product) => {
product.style.display = 'block';
});
seeMoreButton.textContent = 'Show Less';
} else {
// Show only first 6 products
products.forEach((product, index) => {
if (index < 6) {
product.style.display = 'block';
} else {
product.style.display = 'none';
}
});
seeMoreButton.textContent = 'See More Products';
}
}