Ristoph
Ristoph

Reputation: 37

Select All <tds> in Row of Same Button onClick

Good afternoon! I have a table with rows being added with AJAX calls. These tables have a checkbox button. I want to call another AJAX function on a button click and pass the value of the first TD in the same row as the selected checkbox into the function. I know how to do most of it, but what I can't figure out is whether there's a way to get a jQuery object of the row in which a selected checkbox resides? Additionally, why can't I use "this" like this?

$("input:checked").each(function(){
        var parentRow = $(this).parent();

Thanks!

Upvotes: 0

Views: 366

Answers (2)

Tom
Tom

Reputation: 162

Or selector only:

$("tr:contains(input:checked)")

Upvotes: 0

Adil Shaikh
Adil Shaikh

Reputation: 44740

use .closest()

$("input:checked").each(function(){
        var parentRow = $(this).closest('tr');

Upvotes: 1

Related Questions