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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:11:17+00:00 2026-06-06T07:11:17+00:00

I have a DIV which I want to be removed when I click a

  • 0

I have a DIV which I want to be removed when I click a link contained inside that DIV. Here is what I have:

<div id="clients-edit-wrapper">
    <div class="close-wrapper">
        <a href="#" class="close-div">Close</a>
    </div>
</div>

When I click “Close” I want clients-edit-wrapper to be removed. I’m looking for a way to do this by referencing the parent DIV of the Close link which, in this case, is clients-edit-wrapper.

Any help would be greatly appreciated!


Answer from Huangism below:

$('.close-div').click(function(){
   $(this).parent().parent().remove();
});

This only works if the element you would like to remove is two parents up. In my case, this is exactly what I needed.

  • 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-06T07:11:19+00:00Added an answer on June 6, 2026 at 7:11 am

    given your html markup

    Updated to .on()

    $('.close-div').on('click', function(){
        $(this).closest("#clients-edit-wrapper").remove();
    });
    

    More flexibility with .closest, this gives you the option to have more more parents or less parents.

    https://api.jquery.com/closest/

    For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.

    Edit
    (Added related resources)
    Please see jQuery documentation on live()

    As of jQuery 1.7, the .live() method is deprecated. Use .on() to
    attach event handlers. Users of older versions of jQuery should use
    .delegate() in preference to .live().

    As far as I know this is due to memory concerns/issues with live().

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

Sidebar

Related Questions

I have a div.xx-wrapper:hover in CSS which when hovered on, I want to call
So I have a div which will contain 3 buttons and I want these
I want to make a DIV background (which doesn't have a background color) flash
I have on my site a <div> which contains child <div> 's. I want
I have div which has three buttons as, <div id=buttons> <input id=preview class=ButtonStyle type=submit
I have a div which opens when I click a menu button, I am
On clicking a link, a div is created which is draggable. I have another
I have remove which is given as a link. If I click remove I
I have a div, which has jQuery UI Draggable applied. What I want to
I have a selector that binds a click event which will remove the popup.

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.