Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7047801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:48:55+00:00 2026-05-28T02:48:55+00:00

I have a bunch of divs sprinkled throughout a long article. Each one, when

  • 0

I have a bunch of divs sprinkled throughout a long article. Each one, when clicked, shows a span of hidden text within the div. They’re made up of

1) chapter title
2) section number
3) point number

eg: government 3:15 OR whitehouse 15:27 OR legislation 1:38 (there are over 90 chapters).

Using jQuery, i’m trying to see if a chapter title occurs two or more times in a row, if it does, apply a specific class to every one except the first.

Reason being: when referencing these chapter titles, i’ve placed an icon at the beginning:

eg: (icon)Whitehouse 29:8, but I don’t want every single chapter title to have an icon, if that chapter title is referenced two or more times before another chapter title is referenced, then I want the second third forth(etc.) to not have the icon.

Does anyone know how I would go about checking to see if the Chapter Title has been referenced two or more times before a different Chapter Title is referenced?

example:

He spoke of the many injustices in (icon)Whitehouse 3:15, but the president wasn’t speaking of mountains whitehouse 4:2 and whitehouse 4:9. When he saw they were ready to begin (icon)congress 19:4, he said “welcome all to this session” (icon)legislation 9:41, then smacked the prime minister in the face legislation 3:8

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:48:56+00:00Added an answer on May 28, 2026 at 2:48 am

    Encapsulate all references in a set of span tags (or any other container) with a common attribute, but in this case let’s say span.ref.

    I’ve got a basic version of it as the following jsFiddle.

    The HTML required for each chapter title requires the following format:

    <span class="ref">
        <img src="..." />
        <span class="ref-title">Washington</span>
        1:23
    </span>
    

    Then use the following jQuery to update the page:

    $(document).ready(function(){
    
        // var to store the previous reference title
        var previousRefTitle = '';
    
        // cycle through each reference on the page
        $('.ref').each(function(){
    
            // if chapter title is the same as the previous reference
            if ($(this).children('.ref-title').text() == previousRefTitle)
            {
                // change the class
                if ($(this).hasClass('ref'))
                {
                    $(this).removeClass('ref');
                    $(this).addClass('ref-following');    
                }
            }
    
            // if chapter title is new compared to the previous reference
            else
            {
                // update var for next iteration
                previousRefTitle = $(this).children('.ref-title').text();
            }
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of divs with weird id and each of them contains
I have an application creating a bunch of divs through a loop. Each div
I have a bunch of hidden images on my website. Their container DIVs have
I want to toggle a bunch of divs that each have the same id.
I have a parent div, and it houses a bunch of child divs. One
I have a bunch of divs with different combinations of classes in each (e.g.
I have a bunch of divs that are all hidden like this <div class=elements>
I have a bunch of divs I'm trying to organize here. The ones I'm
We have an HTML page which displays a bunch of pretty bars using divs
I have a bunch of images that are displayed in a list view (one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.