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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:38:41+00:00 2026-06-12T20:38:41+00:00

I am trying to create divs dynamically and display them. When I try to

  • 0

I am trying to create divs dynamically and display them. When I try to hide the created divs //First function is working perfect, but that is not what I want. I am defining a close button and I want the div to hide when the close button is cliked. While running the //Second function, after clicking the parent div, it hides all its child divs. I.E. When I click on the 1st div it hides all the divs called after that.

Code:

var newImageBoxdiv = $(document.createElement('div')).attr({ class:"demo"+i, id:"image"});
newImageBoxdiv.html("<img id='MyImage' src='"+d+"'><div class='ImageWindowCloseButton' ></div>");
newImageBoxdiv.insertAfter('.demo');

$('#image').show(); 
i++;

 //First Function
 $('#image').click(function(event){  //Works Perfect

  $(newImageBoxdiv).hide();
  event.stopPropagation();
  event.cancelBubble = true;

 });

 //Second function
 $('.ImageWindowCloseButton').click(function(event){ // Deletes Child element when clicked on parent

  $(newImageBoxdiv).hide();
  event.stopPropagation();
  event.cancelBubble = true;

 });
  • 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-12T20:38:42+00:00Added an answer on June 12, 2026 at 8:38 pm

    $(this).parent(newImageBoxdiv).hide();

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

Sidebar

Related Questions

I'm trying to hide some divs that I have created dynamically using the .hide()
I'm trying to create two buttons that using the hover event, hide some divs
Trying to create collapsible / expandable divs using jQuery, but it's not working for
I'm trying to dynamically create 5 divs that represent 5 days of the week.
I'm trying to create a simple ajax load test script that dynamically creates divs,
I am trying to figure out how to create 3 divs and have them
I'm trying to create slidingUp divs with variable 'top' heights, so that one div
I am trying to dynamically create divs in my Rails app through javascript. However,
I'm trying to create an if-else statement, that will return different divs. I believe
I am trying to create 3 divs that perform as columns. The left should

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.