Read browser JavaScript
const declares a binding that is not reassigned; let allows reassignment. Arrow functions provide concise callbacks. querySelector finds a DOM element and addEventListener responds to input, click or change events. dataset reads data-* attributes on elements.
Combine search and category filters
Normalize the query to lowercase. A card is visible when both its category matches and its title or description matches the query. Reset pagination when filters change. Use a live result count and a visible no-results message.
Update content safely
Use textContent for user-facing plain text and hidden for visibility. Do not concatenate untrusted input into innerHTML. Keep ordinary links functional without JavaScript, and make hover actions available to keyboard and touch users.
Syntax in practice
A focused learning example. Read the referenced source file for its full application context.
search.addEventListener('input', () => {
const query = search.value.trim().toLowerCase();
cards.forEach(card => {
card.hidden = !card.dataset.search.includes(query);
});
});Try it yourself
Search Academy, switch a category, clear both filters, and test a query with zero matches.
Work on a development copy, then explain what changed and how you verified it.
Project file map
Find these paths in your local WebsHigher checkout. Source paths are references, not public downloads of application code.
assets/js/studio-pricing.jsassets/js/travel-template-runtime.jsassets/js/academy.js