Answer the question
In order to leave comments, you need to log in
How to make such a landing catalog?
Tell me the easiest way to make such a postelshop.com product catalog so that you can also switch product categories. I'm a kettle! Something like replacing blocks on click. Does not work.
Answer the question
In order to leave comments, you need to log in
For all products put down tags, you can not just one
<div class="thing-item" data-tags="cat1">
<!-- тут содержимое блока с товаром -->
</div>
<div class="thing-item" data-tags="cat1,catN">
<!-- тут содержимое блока с товаром -->
</div>
<div class="thing-item" data-tags="cat2,catN">
<!-- тут содержимое блока с товаром -->
</div>
<div class="thing-item" data-tags="cat1,cat2">
<!-- тут содержимое блока с товаром -->
</div>
function sortItems(tag){
var items = document.querySelectorAll(".thing-item");
for(var i = 0, max = items.length; i < max i++) {
items[i].style.display = items[i].getAttribute("data-tags").indexOf(tag) != -1 ? "block" : "none";
}
}
<button onclick="sortItems('cat1')">категория 1</button>
<button onclick="sortItems('cat2')">категория 2</button>
<button onclick="sortItems('catN')">категория N</button>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question