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

  • Home
  • SEARCH
  • 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 6594297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:47:33+00:00 2026-05-25T17:47:33+00:00

I have a simple setup, a table whose cells have checkboxes within them. I

  • 0

I have a simple setup, a table whose cells have checkboxes within them. I have two events, one that responds to clicking on the checkboxes and another which responds to clicking on the “tr” elements. When I click on a checkbox I don’t want the table row event to fire. I’ve tried event.stopPropagation() and return false; without any luck. Here’s a snippet:

$("tr").click(function() {
    alert("tr clicked");
});

$("input[type=checkbox]").change(function(event) {
    event.stopPropagation();
    alert("checkbox clicked");
});

With something like:

<tr>
    <td><input type="checkbox" id="something" name="something" /></td>
</tr>

If the change event fires the click event will also fire. Any clues on how to stop the tr click event from firing if the checkbox is changed within the td element of the tr?

  • 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-05-25T17:47:33+00:00Added an answer on May 25, 2026 at 5:47 pm

    I recommend this:

    $( '#theTable' ).delegate( 'tr', 'click', function ( e ) {
        if ( $( e.target ).is( 'input:checkbox' ) ) { 
            alert( 'checkbox clicked' );
        } else {
            alert( 'tr clicked' );
        }        
    });
    

    So, you have only one click handler for the entire table.

    Btw, you don’t have to place all the code inside this one handler. You can have separate functions for each action (checkbox clicked VS row clicked), and then…

    $( '#theTable' ).delegate( 'tr', 'click', function ( e ) {
        if ( $( e.target ).is( 'input:checkbox' ) ) { 
            checkboxClicked( e );
        } else {
            rowClicked( e );
        }        
    });
    
    function checkboxClicked ( e ) {
        // process event
    }
    
    function rowClicked ( e ) {
        // process event
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple MySQL table that is setup for full text search. |
I have a very simple Setup project that copies three dlls into the GAC.
I have a really simple ASP.NET web application and a web setup project that
So my database setup is fairly simple. I have a forum_cat table (a forum
I have setup a simple while loop which returns all images in a table
Setup using a simple example: I've got 1 table ( Totals ) that holds
The setup is simple, a Master table and a linked Child table (one master,
I have successfully setup a simple mvc application that lists teams. I'm using Ninject
If I have a simple class setup like this: class MyClass { private string
I have a simple client/server setup. The server is in C and the client

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.