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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:21:19+00:00 2026-06-12T10:21:19+00:00

This question is in relation to a question I posted yesterday. The link -http://stackoverflow.com/questions/12636348/how-to-add-a-different-class-to-the-same-class-in-jquery

  • 0

This question is in relation to a question I posted yesterday. The link -http://stackoverflow.com/questions/12636348/how-to-add-a-different-class-to-the-same-class-in-jquery . The question and problem now is that I will like to have a div added after the div with the class being added. The problem is the script that I’m using adds the div only to an existing/default class name and not the added class via JQuery. The script is below.

 $(document).ready(function(){$('.example').each(function(i){$(this).addClass("ex" + i);});

 $('.ex0').after(function(){return'<div class="afterdiv"><a class="afterdiva1" href="#" title="Text."></a><a class="afterdiva2" href="#" title="Text."></a></div>'});

The default output is:

      <div class="example"></div>

The final html output should read as:

      <div class="example ex0"></div>
      <div class="afterdiv">
      <a class="afterdiva1"></a>
      <a class="afterdiva2"></a>
      </div>

Update- I apologize for not clarifying that each div needs to be unique to/per class. Sincere apologies (I’m new to asking for help here or anywhere else for that matter).

  • 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-12T10:21:20+00:00Added an answer on June 12, 2026 at 10:21 am

    You should put all these calls into the .ready() function. Right now, the second line is executed before the DOM ready callback (because .ready() is an asynchrone function).

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

Sidebar

Related Questions

My question is in relation this this answer. https://stackoverflow.com/a/8773953/1297775 I have read at many
In relation to this stackoverflow question , how would I go about creating my
In relation to this question: StackOverflow - Grouping radio buttons in c# mvc I
I'm currently working on a site http://www.lovepotatoes.ovh3.microserveltd.co.uk/ and this question is in relation to
In relation to a question I posted on here yesterday, I am trying to
Now, I have read these questions which may have a relation with this question:
This is in relation to this question . The proposed answers involve adding a
In relation to this question ( Efficient hashCode() implementation ) I have one more
In relation to this question: Remove unused references (!= "using") , I would like
This question is in relation to another question asked here: Sorting 1M records I

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.