Skip to content
Advertisement

Show posts of active category through jQuery

I have a page with different prizes, divided over 4 categories. When the page loads, the first category gets the ‘active’ class and I need the corresponding prizes to show at that moment.

The code works when I click on one of the categories, but when the page loads, none of the prizes are showing. Is there a way to detect which category has the ‘active’ class and the show the right prizes?

This is the page: https://staging.mytimo.be/prijzen/

jQuery

JavaScript

PHP

JavaScript

Advertisement

Answer

You can trigger the click event on your active item.

JavaScript

Do this inside your $(document).ready(...); call but after you add the active class and attach the click event handler.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement