Q:

jquery - set a variable equal to the nearest checkbox object with specified name

I have a table with multiple rows. each row has the same inputs names with an incremental number attached to it.
<table class="table.authors-list">
    <tr>
        <td>
            <input type="text" name="first_name_1" id="first_name_1">
            <input type="text" name="last_name_1" id="first_name_1">
            <input type="checkbox" name="treated_1" id="treated_1">
        </td>
    </tr>
    <tr>
        <td>
            <input type="text" name="first_name_2" id="first_name_2">
            <input type="text" name="last_name_2" id="first_name_2">
            <input type="checkbox" name="treated_2" id="treated_2">
        </td>
    </tr>
    <tr>
        <td>
            <input type="text" name="first_name_3" id="first_name_3">
            <input type="text" name="last_name_3" id="first_name_3">
            <input type="checkbox" name="treated_3" id="treated_3">
        </td>
    </tr>
</table>

on entering information into first_name_2, I want to 
my jquery function is:
function calculateRow(row, cb) {
    if ($(cb).is(':checked')) {
        alert(1);
    } else {
        alert(2);
    }
}

I want to call function calculateRow() with the below syntax
$("table.authors-list").on("change", 'input[name^="discount"]', function (event) {
    var cb = $(this).closest(input[name ^= "treated"]);
    calculateRow($(this).closest("tr"), cb);

});

I want to pass two parameters to calculateRow()
row is $(this).closest("tr")
for cb I want it to be the checkbox field.
var cb = $(this).closest(input[name^="treated"]);
so when calculateRow() executes, the code will check the value of the checkbox named treatedX where X is the number of that row.
I have tried to create a fiddle, but it is not working obviously.
http://jsfiddle.net/cmJu6/
so basically, on entering something into the first_name input, the alert must fire depending on if the checkbox is checked or not.
Thanks in advance

A:

use .siblings instead of closest to get the sibling input-
$(this).siblings('input[name^="treated_"]');

Also, your selector is wrong --> $("table.authors-list")
it should be like $(".table\\.authors-list")
Demo ----> http://jsfiddle.net/cmJu6/2/

