0

I have a table that contains several rows each containing one checknox. Checkbox will get selected on the row click event. Now how can I apply an onclick event for a checkbox?

$('input[type=checkbox]').click(function() {      
  countPopChecked();           
});  

This is my script. This is working when I click on the checkbox. But I want this functionality when I am clicking on the table row.

1 Answer 1

5
$('input[type="checkbox"]').closest('tr').on('click', function() {      
    countPopChecked();           
}); 

or :

$('tr').has('input[type="checkbox"]').on('click', function() {      
    countPopChecked();           
}); 
Sign up to request clarification or add additional context in comments.

2 Comments

this is not working for me.. Giving $('input[type="checkbox"]').closest('tr').on is not a function
@praji - your version of jQuery is way to old, update to 1.9.1, or at least something above 1.7 to make on() work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.