Callum Linington
Callum Linington

Reputation: 14417

Jquery using selectors after a selector has been used

So I have this:

<tr id="thisRow">
    <td>
        <label for="pen1">Pen 1</label><input type="checkbox" name="pen1" /><br />
        <label for="pen2">Pen 2</label><input type="checkbox" name="pen2" /><br />
    </td>
</tr>

I use this jquery to get the row:

function GetRow(value) {
   var row = $("#"+value);

}

Now I have the row in memory, I really want to start modify a few cells in that row and then adding it to a different table altogether...

So I want to do this for example:

function GetRow(value) {
    var row = $("#"+value);
    row.select("td:nth-child(2) input[type='checkbox']").each(function () {

});
}

I know its not correct but you get the idea!

Upvotes: 0

Views: 61

Answers (1)

Per Salbark
Per Salbark

Reputation: 3645

I think you are looking for $.find() or $.children(). Like this:

row.find("td:nth-child(2) input[type='checkbox']").each(function () {
});

Upvotes: 2

Related Questions