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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:24:30+00:00 2026-06-09T05:24:30+00:00

I am utilizing the jQuery UI, the accordion specifically. I wanted to add a

  • 0

I am utilizing the jQuery UI, the accordion specifically. I wanted to add a “remove” button to each accordion that would hide it.

My current code just sets the visibility to hidden on the div. But, I need to completely remove the accordion.

Here is how I have my html laid out.

<div class="my-accordion">
    <h3>Accordion 1</h3>
    <div>
        <p>derp</p>
        <div class="remove">REMOVE</div>  
    </div>
    <h3>Accordion 2</h3>
    <div>
        <p>derp</p>
        <div class="remove">REMOVE</div>  
    </div>
    <h3>Accordion 3</h3>
    <div>
        <p>derp</p>
        <div class="remove">REMOVE</div>  
    </div>
</div>

And, here is my jQuery.

$(function() {
    $( ".my-accordion" ).accordion();
});

// This is a giant failure.
$('.remove').click(function(e) {
        $(this).parent().hide();
        e.preventDefault();
});
  • 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-09T05:24:32+00:00Added an answer on June 9, 2026 at 5:24 am
    $('.remove').click(function(e) {
        var parent = $(this).parent('div');
        parent   // parent div of REMOVE
          .prev('h3') // catch previous h3
          .andSelf()  // parent div
          .remove();  // remove both parent div and h3
    });
    

    DEMO

    To remove the parent div use .remove().

    OR in a row

    $('.remove').click(function(e) {
        $(this).parent('div').prev('h3').andSelf().remove();
    });
    

    DEMO

    Note

    It would be better if you can wrap each accordion within a div wrapper like below:

    HTML

    <div class="my-accordion">
        <div class="accordion-wrapper">
           <h3>Accordion 1</h3>
           <div>
            <p>derp</p>
            <div class="remove">REMOVE</div>  
           </div>
         </div>
        .....
    </div>
    

    and change the jQuery code like:

    $('.remove').click(function(e) {
        $(this).parents('div.accordion-wrapper').remove();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The debug build of some code utilizing SFHFKeychainUtils that is working without complaint on
I'm writing a system utilizing jQuery Validation that pulls in custom rules, messages via
I have a page that is currently utilizing a jQuery plug-in for truncating text
i am going to be utilizing a flash/jquery powered gallery on a webpage that
Utilizing jQuery Address to enable the browser's back button, I was able to leverage
I have two post requests I'm making utilizing jquery and a method that uses
I'm working on an asp.net app that is utilizing a lot of jQuery UI
I have created a great stand-alone web form in asp.net utilizing many jQuery features
I am utilising the callback function of jQuery's .load method to run certain code
Is there any way (utilizing Reflection I hope) that I can make an instantiated

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.