$('#deleteMessage').click(function () {
$.each('input:checked', function () {
var tr = $(this).closest('tr');
alert(tr.id);
});
});
Here is the HTML:
<tr>
<th width="40"> <input type="checkbox" name="checkAll"></th>
<th width="120">From</th>
<th width="500">Subject</th>
<th width="140">Date</th>
</tr>
<tr replytoid="3" messageid="2664" id="15" class="messageNew">
<td> <input type="checkbox" name="checkAll"></td>
<td>John Doe</td>
<td>asd</td>
<td>3/14/2012 1:09:04 PM</td>
</tr>
I need this to loop through each checked box (excluding the one inside the <th>). I then need it to find the <tr> the checkbox is inside of, and grab that id. I can’t seem to get this to work.
You aren’t using the correct version of
$.eachfor this scenario. Try this:Also,
tris a jquery object, use[0]or.get(0)to get back to the dom element to get it’s ID property.