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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:53:40+00:00 2026-06-15T23:53:40+00:00

I have a div with an id of close inside a dynamically created div

  • 0

I have a div with an id of “close” inside a dynamically created div with an id of “box”. The following code is meant to do something whenever the user clicks on close.

$('#box').on('click','#close',function(){
    alert(1); // Test to see if the click works
});

I’m using the Big Cartel CMS and if I click close in the “live preview mode”, it seems to work fine, but whenever I actually publish the site and view it normally, it does absolutely nothing – no errors – nada.

Markup & CSS, just in case:

<div id="box"> <!-- Dynamically loaded -->
    <div id="close"></div>
    <h2 id="name"></h2>
    <div id="description">
        <p>blah...</p>
    </div>
</div>

#close{
    background: url(image-path);
    float: right;
    position: relative;
    top: 0;
    margin: 0 0 0 12px;
    width: 25px;
    height: 25px;
    cursor: pointer;
    z-index: 100;
}

What am I missing?

  • 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-15T23:53:41+00:00Added an answer on June 15, 2026 at 11:53 pm

    The problem is because #box is also dynamic. You need the primary selector to be an element which is available when the page is loaded.

    A primary candidate would be the element in to which you are loading #box.

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

Sidebar

Related Questions

I have an slider animation but on clX.click event #close div hides before it
I have a page that dynamically generates any number of divs.  Inside the div
I have some div with its click actions and another div inside first -
I have a setup like this: <div id=container> <div id=close>Close</div> </div> Then in my
I have div(box) on my page and I'm using this script to display div
I am trying to create a jQuery click function that will close a div
I have a couple of update panels inside a user control. One of the
I have two simple scripts, the first shows a div when clicked. Inside that
I have the following inside a richfaces modalpanel: <ui:repeat id=al11 var=albumslistvalue1 value=#{AlbumDetailBean.getAlbumImagesList()} varStatus=albumslistvalue1Index> <rich:modalPanel
I have this code for a JQuery a dialog for a div containing a

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.