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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:15:09+00:00 2026-06-17T10:15:09+00:00

when I click a button, i appended (inserted) after it a div with new

  • 0

when I click a button, i appended (inserted) after it a div with new div, and i donot want to give id to the new div, because i want this function could be use by other button/anchor/etc.

$("#buttonA").click(function(){
$("#div1").after("<div>bla bla bla</div>");
});

and then by an event i want to remove the inserted div.
what’s the best way to remove inserted div? … i still cant make it generic, i must apply ID on the new inserted div, and then to remove it i use

$("#newid").remove() 
  • 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-17T10:15:10+00:00Added an answer on June 17, 2026 at 10:15 am

    First mark the inserted element with a tag (in this case, the inserted class):

    $("#buttonA").click(function(){
        $("#div1").after("<div class='inserted'>bla bla bla</div>");
    });
    

    Then look for the inserted element using the selector of your choice:

    $("#div1 .inserted").remove();
    

    You could also remove every div inserted this way:

    $(".inserted").remove();
    

    If your intention is to allow many different events to create many different divs all inside the same container, and then remove one particular div, then you are going to need to either generate unique ids for each div and map them to the callers for later reference, or simply map the created div element to the callers for later reference. It’s hard to make a strong suggestion without knowing more about your use case.

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

Sidebar

Related Questions

click the button to call this method: private void goRegister(final boolean isUsername) { new
When click a button,I want to popup a view form bottom,like this! Any help
I am trying to use some action when I click button in navigation controller.
In button click event I am writing this code.(code behind).I know button click event
My code is as follows: <script> $(document).ready(function() { var tagCounter=0; $(#tag-add-button).click(function () { var
I have a DIV element. <div id=testButton> Test Button </div> I'm gonna click on
html: <div class=box> <div><p>Hello World</p></div> </div> <input type=button id=add value=Add /> jquery: $(document).ready(function(){ var
Initially, when users click the delete button, I want the whole line of elements
I want to add views on click of button. My screen has a text
I have a function where on button click I add columns, now what I

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.