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 8752955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:20:14+00:00 2026-06-13T13:20:14+00:00

I have a structure like this <div class=dynamic id=thumbnail-div> <p id=thumbnail-p> <a href=#> <img

  • 0

I have a structure like this

        <div class="dynamic" id="thumbnail-div">
            <p id="thumbnail-p">
                <a href="#">
                    <img src="images/circle.GIF" alt="Example Number 1 For Display Case" name="Example Number 1 For Display Case" class="dynamic" id="thumbnail-img" />
                </a>
            </p>
        </div>

There are multiples of that html structure above so there could be like 10, 20, 50, etc. Now what I am trying to do is have jQuery change the classes to all the elements with the id of “thumbnail-div” to something like thumb1, thumb2, thumb3, etc.. so they should count up depending on how many there are. I cannot find a way to achieve this and after a lot of research I have found nothing helpful. Please help.

Thanks in advance!

  • 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-06-13T13:20:15+00:00Added an answer on June 13, 2026 at 1:20 pm

    You seem to having duplicated ID’s on your page ..

    I am afraid if you try to access these elements with ID it will only retrieve the first element with that ID..

    Lets say all your div’s in Question has the .dynamic class.. Then you can do something like this

    $('div.dynamic').each(function(i){
    
         $(this).addClass('thumb' + (i+1));   // Add Class
         $(this).attr('id' , 'thumb' + (i+1));  // Set id for each div 
    });
    

    Check FIDDLE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML structure like this:- <article id=a_post class=a_post> <div id=thumbnail> <img id=shine
I have the following html structure: <div class=divClass> <a class=aClass href=#> <img src=xxxx.jpg <span
let's say I have an HTML structure like this: <div class=first> <div class=sub-1> <div
I have structure like this <div id=mali_oglasi> <p class=mali_oglas> <span class=name>Predaja7</span> <span class=body>Lorem ipsum
I have a html structure like this: <div class=one> <div id=two> <h2>Any</h2> <h4>Any</h4> </div>
I am trying to use jQuery(#element-id).parent().addClass('some-class'); I have a structure something like this: <div
I have a div structure like this [simple menu]: <div class=float menuA> <div class=float
I have a DOM structure that looks like this: <div class=chapter> <section></section> <section></section> </div>
I have a structure like this: <div class=content> <div class=board></div> </div> then, here is
I have the html structure like this <div class=selected> <div class=selectedOption>September 2012</div> </div> <div

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.