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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:04:05+00:00 2026-06-10T04:04:05+00:00

I have the following HTML: <table> <tr> <td><button class=foo type=button>Click Me</button></td> </tr> <tr> <td><button

  • 0

I have the following HTML:

<table>
    <tr>
        <td><button class="foo" type="button">Click Me</button></td>
    </tr>
    <tr>
        <td><button class="foo" type="button">Click Me</button></td>
    </tr>
</table>

I want to have a click handler for button.foo only execute once, but I don’t want jQuery to remove the handlers from other elements. So when you click the first button, it removes the handler for that button, but not the second button. When you click the second button, it removes the handler for the second button, but not the first button.

Also, when any buttons with the class “foo” are added to the table, I want it to add a click handler that will be removed the first time it is used, and again, not remove other handlers.

$("table").one("click", "button.foo", function() {
    // ...
});

The above code doesn’t work because it removes all handlers the first time any element is clicked. Is there a way to accomplish what I’m asking easily?

  • 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-10T04:04:07+00:00Added an answer on June 10, 2026 at 4:04 am

    You can remove the class after the click event.

    $("table").on("click", "button.foo", function() {
        alert("click!");
        $(this).removeClass("foo");
    });
    

    See DEMO.

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

Sidebar

Related Questions

I have the following html: <table> <tr> <td> <input type=button id=btnAdd value=Add /> <input
I have the following html table <table id={64ED3A94-5833-4CC7-869F-CCE583B498BE} class=ms-listviewtable width=100% cellspacing=0 cellpadding=1 border=0 xmlns:o=urn:schemas-microsoft-com:office:office
I have the following HTML table: <table style=width: 100%;> <tr> <td class=title_bar_left_border></td> <td class=title_bar_middle></td>
I have the following HTML generated by an ASP.NET repeater: <table> <tr> <td><input type=hidden
I have the following html code: <form> <table> <tbody> <tr> <td> <span>Quantity<span class=pull-right>3</span> <input
I have a HTML table with following content. <table class='main'> <tr id='r1' class='tbl'> <td>V1</td>
I have the following HTML: <table id=MwDataList class=data width=100% cellspacing=10px> .... <td class=centerText style=height:
I have the following html code: <table> <tr> <td> <div id=fixmywidth style=position:relative; height:30px;> <div
I have the following code to access a HTML table. my $table = $tree->look_down(_tag
I have the following html structure (which is generated and I can't change): <table

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.