ARTICLE AD BOX
I can see the navigation click calls fetchNews() correctly, but you mentioned the active class is not being applied. That's because your onclickNav function only fetches news but doesn't update the visual state of the navbar.
Add logic to handle the active class:
let currentActiveNav = null; function onclickNav(id) { // Remove active class from previously selected item if (currentActiveNav) { currentActiveNav.classList.remove("active"); } // Add active class to clicked item const clickedItem = document.getElementById(id); clickedItem.classList.add("active"); currentActiveNav = clickedItem; // Fetch the news fetchNews(id); }And you can set default active on page load
window.addEventListener('DOMContentLoaded', () => { onclickNav('ipl'); // Load IPL news by default });