Mahendra
document.addEventListener('DOMContentLoaded', () => {
const indexPage = document.querySelector('.IndexPage');
const carousel = document.querySelector('.carousel');
const hideCarousel = () => {
if (indexPage && indexPage.className.includes('IndexPage--tag')) {
carousel?.style.setProperty('display', 'none', 'important');
}
};
hideCarousel();
// check
const observer = new MutationObserver(hideCarousel);
observer.observe(document.body, { childList: true, subtree: true });
});
This script should hide the .carousel element immediately and also handle cases where content may be added dynamically after the page load. It listens for changes to the DOM and runs the hideCarousel function when updates occur.
Note: I'm building upon the code Devonab provided, and I forgot to mention this in my previous reply.