JQuery get selected table rows with checkbox

by Alvin Olavarrieta

HTML

<table id="rowclick2">
    <tbody>
        <tr id="tr1">
            <td class="cb"><input type="checkbox" value="yes"></td>
            <td>row 1</td>
            <td>A</td>
        </tr>    
        <tr id="tr2">
            <td class="cb"><input type="checkbox" value="yes" ></td>
            <td>row 2</td>
            <td>B</td>
        </tr>    
        <tr id="tr3">
            <td class="cb"><input type="checkbox" value="yes"></td>
            <td>row 3</td>
            <td>C</td>  
        </tr>    
    </tbody>
</table>

<button id="test">TEST</button>
<p id="out"></p>

JavaScript

$('#test').click(function() {
    $('#out').text('');
    $('#rowclick2 tr').filter(':has(:checkbox:checked)').each(function() {
        // this = tr
        $tr = $(this);
        $('td', $tr).each(function() {
            // If you need to iterate the TD's
        });
        //get row values
        $('#out').append(this.id);
    });
});