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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:29:40+00:00 2026-05-19T16:29:40+00:00

I have a quick jQuery question: I have the following type of table: <table

  • 0

I have a quick jQuery question:

I have the following type of table:

<table id="my_table">
  <tr>
   <td><input type="checkbox" value="24"></td>
   <td> Click Here To Check The Box </td>
   <td> Or Click Here </td>
  </tr>
 </table>

And in jQuery, I am attempting to select the corresponding checkbox in that row that was clicked.

 $("#my_table tr").click(function(e) { 
     $(this).closest(":checkbox").attr("checked", checked");
  });

But the above isn’t working. Any quick ideas on selecting the checkbox on the row that was clicked? Thanks!

  • 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-19T16:29:41+00:00Added an answer on May 19, 2026 at 4:29 pm

    EDIT: BEST SOLUTION AT BOTTOM

    Assuming there’s only one checkbox, I would attach the event to the td instead of the tr:

    $('#my_table td').click(function(e){
      $(this).parent().find('input:checkbox:first').attr('checked', 'checked');
    });
    

    Example

    If you want to be able to uncheck the checkbox as well…

    $('#my_table td').click(function(e) {
        var $tc = $(this).parent().find('input:checkbox:first'),
            tv = $tc.attr('checked');
    
        $tc.attr('checked', !tv);
    });
    

    This function needs to be applied to the checkbox as well to negate the default behavior.

    Example 2

    EDIT: The solution is most reasonable method is to cancel the functionality if the target is an input: http://jsfiddle.net/EXVYU/5/

    var cbcfn = function(e) {
        if (e.target.tagName.toUpperCase() != "INPUT") {
            var $tc = $(this).parent().find('input:checkbox:first'),
                tv = $tc.attr('checked');
            $tc.attr('checked', !tv);
        }
    };
    
    $('#my_table td').live('click', cbcfn);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question... I have an input box that upon key enter, adds the value
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
I have a quick question of how I can use jQuery tabs (you click
I have a quick, beginners-type-question. If I were to use jQuery and some other
Just a quick question... I currently have the following jQuery code with a selector
quick question here. I'm looking for a way to populate my JQuery search box,
I have a quick question about keyup with jquery. I have several form input
I have a quick question. I am using jQuery-Mobile for mobile web development. I
I have quick question about jQuery plugins, hope somebody out there has some advice.
I have a quick jQuery/css question. I am coding a site and have a

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.