I have a table 'mytable' that looks like:
<tr>
<td><input type="checkbox" name="check[]" value="11"></td>
<td>11</td>
<td>2014-11-06 18:49:26</td>
<td>MESSAGE</td>
<td></td>
<td>MATCH5</td>
<td>NO MATCH</td>
<td>NO MATCH</td>
</tr>
I want to get the value of column 4 "MESSAGE" from a row if its checked
as you can see each row begins with a checkbox which have a value. however the value is non-sequential so I can't just go with the checkbox value (which I have been getting with
var IDs = $('input:checked').map(function(){
return $(this).val();
}).get();)
I need some way of counting table rows then I can use something like:
var id= $("#myTable tr").eq(ID).find('td').eq(4).val()
How to do this?
You were pretty close but consider what this
is in the context of map()
.
this
is the checkbox that is checked. From there you can find the closest tr
and then the td
with the 3rd 0-based index, and then get the text()
of that td
. td
doesn't have a value
so use text
instead.
var ids = $('table input:checked').map(function(){
return $(this).closest('tr').find('td:eq(3)').text();
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments