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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:54:36+00:00 2026-05-30T01:54:36+00:00

Here is a simplified example of what i’m working with, working around preexisting code:

  • 0

Here is a simplified example of what i’m working with, working around preexisting code:

Basically I have 2 divs I want to hide/show in multiple places(stage 1, stage 2, stage 3,etc), as so:

var blue_div = "#Blue";
var red_div = "#Red";
var blue_stage = "#Blue" + count;
var red_stage = "#Red" + count;

Adding insult to injury the div’s exist elsewhere on page and are hidden. Need to pull the content into another div for each stage. So i’m using .prepend() to grab the content, as so:

var blue_html = $(blue_div).html();
var new_div = "#new_div";

$(new_div).prepend(blue_html);
$(new_div).attr('id', blue_stage); //Changing the id based on the stage

That last part is really whats throwing me…As now I’m trying to use the new_div without first ending the script so it’s not yet in the DOM…

if ($(blue_stage).is(':hidden')) {
    $(blue_stage).show()
    $("#cancel").bind("click",function(){
        $(blue_stage).hide()
    }
}

I’ve seen a lot done with Window setTimeout() as well as setinterval and .queue(). But my attempts have all failed. Hopefully my example wasn’t confusing, any help at all is appreciated!

  • 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-30T01:54:37+00:00Added an answer on May 30, 2026 at 1:54 am

    I think you can do something like this:

    var $new_div = $('<div id="' + blue_stage + '"></div>');
    

    which will allow you to edit the element directly so you can do things like:

    $new_div.prepend(blue_html);
    

    to change the id you do:

    $new_div.attr('id', blue_stage)
    

    and note when your setting the id like this you don’t need the “#” as the other answer mentions

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

Sidebar

Related Questions

Here is a simplified version of what I have (not working): prog.h: ... const
I have some code where I'm returning an array of objects. Here's a simplified
I'll give a simplified example here. Suppose I have an iterator in python, and
Here's a simplified example of my problem. I have a table where there's a
A simplified example here: I have a game that I am writing in opengl
Here's a simplified example of what I'm trying to do: I have 2 controls
I ran into some code today that I found questionable. Here's a simplified example
I cannot find the solution for this problem, here is the simplified example: On
Here is simplified version of my requirement I have a java class say Processor
I want to list all users with their corropsonding user class. Here are simplified

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.