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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:28:25+00:00 2026-06-05T14:28:25+00:00

So, I have a template div like this: <div class=’container’> <div class=’mybox invisible’ id=’template’>

  • 0

So, I have a template div like this:

<div class='container'>
  <div class='mybox invisible' id='template'>
     <span>some stuff</span>
     <div>test</div>
  </div>
</div>

So I want to clone it to create items based on it.

new_item = $('#template').clone()
$(new_item).removeClass('invisible').attr('id','some_crap').appendTo('.container')

It works beautifully.
BUT, if I run this code ON DOCUMENT READY (to pre-load some items), then everything gets an inline visibility: hidden added (the .mybox div, and ALL its children).

My workaround for now is, instead of pre-loading my items on dom ready, waiting 1 second.

setTimeout (->
    preloadOffices()
), 1000

(yea, coffeescript)

That seems to do the trick, but I’m wondering if there are more elegant solutions.

  • 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-05T14:28:28+00:00Added an answer on June 5, 2026 at 2:28 pm

    .clone() does not add arbitrary style values to the objects it clones. As such, I think there are only two possible explanations here:

    1. The objects are actually visibility: hidden at document.ready() time and some code is actually making your other object visible later. .clone() just makes copies of the objects as they are. It doesn’t add arbitrary style values to them.

    2. Some other code is making your cloned object visibility: hidden after you clone it.

    If you showed us your actual page, we could likely figure out what was really happening.

    You can debug this yourself by stepping through your code and watching what state things are in as the code runs. Or, you can insert some console.log statements that examine what state things are in.

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

Sidebar

Related Questions

Might be a newbie question. I have a code line like this: <div class=template
I have a template like this: <script id=notesTemplate type=text/html> <li class=Note> <div class=NoteDate data-bind=style:
Say I have jquery code like this: html += '<div class=index>' + item.index +
I have a piece of code working in knockout.js like this: <div> ... some
I have a view like this: <div id=basic-information-container> @Html.Action(MyBasicInformation) </div> <div id=cv-container> @Html.Action(MyCv) </div>
I have template that looks like this: 100 template<size_t A0, size_t A1, size_t A2,
I have a template class defined like so: template <class T> class Command {
I would like to put some help text in this form. class ItemForm(forms.ModelForm): alternative_id
I have a product template that looks like this: The html for it is:
I have a form in my template like this : <form action=. method=GET style=font-family:

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.