Skip to main content

Limit subteasers 

Add to Sitewide advanced - need to update for your site. in action on eldoradocountyfire.com
//LIMITS AMPLIFY SUBTEASERS ON "IN THE NEWS"
<script>
document.addEventListener("DOMContentLoaded", function() {
  // 1) Select every <article> that uses your “standard‐teaser” structure
  const articles = document.querySelectorAll("article.amplify-target-locator.cards");
  
  articles.forEach(article => {
    // 2) Inside each article, find the <p class="heading"> element
    const headingElem = article.querySelector(".standard-teaser-content-container .heading");
    if (!headingElem) return;
    
    // 3) Do a loose “contains” check on the text so that invisible characters or extra spaces
    //    don’t prevent a match. We only care that it mentions “News” here.
    const headingText = headingElem.textContent.trim();
    if (!headingText.includes("News")) return;
    
    // 4) Grab all <li> under .nested-teasers → ul
    const listItems = article.querySelectorAll(".nested-teasers ul li");
    
    // 5) Hide everything after the first six (index 0–5 remain visible)
    listItems.forEach((li, idx) => {
      if (idx >= 6) {
        li.style.display = "none";
      }
    });
  });
});
</script>