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

  • Home
  • SEARCH
  • 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 288233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:47:51+00:00 2026-05-12T05:47:51+00:00

I basically have several divs each with ids id_1, id_2 id_3 etc. The divs

  • 0

I basically have several divs each with ids “id_1”, “id_2” “id_3” etc. The divs are all initially empty.

I want on page load to populate all the divs with certain html content. But the part that has been troubling me is that I also need to extract the unique id portion for use within the html:

<div id="id_3">
     <div id="inner_3></div>
</div>

where the inner div is what gets printed. Notice that the ‘3’ is extracted from the container div id by the javascript and then subsequently used and printed in the inner div.

Any ideas how to do this with jquery? 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-05-12T05:47:51+00:00Added an answer on May 12, 2026 at 5:47 am

    You can fetch all the div elements that have an id that starts with a certain string:

    $(function() {
        $('div[id^=id_]').each(function() {
            var id = $(this).attr('id').split('_').pop();
            $(this).html(
                $('<div/>').attr('id','inner_' + id)
            );
        });
    });
    

    Then you loop through each, get the id, and do your HTML manipulation.

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

Sidebar

Related Questions

i have two divs on a page. each has several dijits. i have atoggle
Basically I have several divs, each contains a question. This question could be presented
i have the following jquery code. basically i will have several overlapped divs and
I have a block of code that basically intializes several classes, but they are
I basically have a page which shows a processing screen which has been flushed
I have a div container inside which there are several child divs with css
I have several floating divs, which are graphically arranged thusly (their hierarchy in the
Basically, what the title says. I have several properties that combine together to really
I need to duplicate several tables in a single database. Basically we have an
I have several activities in my app. I want my activities to have the

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.