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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:16:23+00:00 2026-06-12T09:16:23+00:00

Erm, why this don`t work, iv used similar code like this for my site

  • 0

Erm, why this don`t work, iv used similar code like this for my site many times..butnow dont work..

HTML

<div><span>a</span><input type='hidden' /> <input type='button' onClick='Remove(event)' />

JQuery

function Remove(e){
e.preventDefault();
$(this).closest('div').remove();
}

Looks like $(this) is not my button. I tested with alert($(this).val()) and nothing heppend.

enter image description here

  • 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-12T09:16:24+00:00Added an answer on June 12, 2026 at 9:16 am

    How about adding a class to the button element and bind a handler to the button

    <div>
       <span>a</span>
       <input type='hidden' /> 
       <input type='button' class'removeDiv' />
    

    Code:

    $(function () {
        $('.removeDiv').click (function () { 
             $(this).parent().remove();
             // As I see the input is direct child of the div
        });
    });
    

    My divs are created from clientside and serverside too. Its much easy to add onclick function instead to unbind-rebind all on new item, no?

    In such cases you can use delegated events. See below,

    $(function () {
        //Replace document with any closest container that is available on load.
        $(document).on('click', '.removeDiv', function () { 
             $(this).parent().remove();
             // As I see the input is direct child of the div
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading this question , in the first comment, @Cody Gray says: Erm, you know
Erm... i promise i searched thoroughly the web for this and couldn't find a
This is probably a real simple one. I wished to create some code inside
Erm, that's it!...
Ok so I have this storedproc in my SQL 2008 database (works in 2005
Consider the following code snippet: list<someClass>& method(); .... list<someClass> test = method(); What will
I'm pretty certain I'm missing something really obvious here but this seems quite bizarre.
I need to abstract some behavioural code and have a problem trying to reference
Can't find info bout this anywhere on the internet. I got a list of
That is, why does this: struct S {}; struct T { T(S& s) :

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.