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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:46:23+00:00 2026-06-18T04:46:23+00:00

So.. This one should be simple. I have an anchor element. When it is

  • 0

So.. This one should be simple. I have an anchor element. When it is clicked, I want to call a function that will delete it’s parent element. Essentially, it is a link to remove the parent.

How would I accomplish this? I have tried using the following, which is not working:

<div>
     <a href='javascript:removeParent()'>Remove</a>
</div>
<script>
function removeParent() {
     $( this ).parent().remove()
}
</script>

Can anyone help me out?

I’m trying to accomplish this because it is a form that can have multiple attributes… So you can add more attributes and thus need a way to remove them.

Cheers!

  • 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-18T04:46:24+00:00Added an answer on June 18, 2026 at 4:46 am

    $(this) isn’t the element the way you’re doing it.

    Ideally, this:

    <a href='#' class='remove'>Remove</a>
    
    $('.remove').on('click', function(e){
        e.preventDefault();
        $(this).parent().remove();
    });
    

    However this part of your question “So you can add more attributes and thus need a way to remove them.” means you need to apply this to future elements

    $(document).on('click', '.remove', function(e){
        e.preventDefault();
        $(this).parent().remove();
    });
    

    Though in an ideal situation you’d give jQuery less to search, so give your list wrapper an ID and use that to identify the removable elements.

    $('#attributelist').on('click', '.remove', function(e){
        e.preventDefault();
        $(this).parent().remove();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one should be pretty simple. The use case is that I have a
Ok,now I cant figure this one, that should be really simple.I have read so
This should be a simple one: I have an observableArray object called To in
Let's say that some function returns object reference. How one should properly spell: this
I have a simple script that should cause one of three divs to be
Let’s say that we have a very simple QML file, like this one: import
This one should be simple, but I can't figure it out myself. I have
Ok, this one should be simple. I have 3 dictionaries. They are all made,
This should be simple enough. Here's my one line of code that's giving me
This should be a simple one and I am dissapointed with myself but cant

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.