我有一个表“mytable”,如下所示:
<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>
如果选中,我想从行中获取第 4 列“MESSAGE”的值。在 How to get value of table cell with jquery from checkbox using absolute row number结果表明
var ids = $('table input:checked').map(function(){
return $(this).closest('tr').find('td:eq(3)').text();
});
返回
Object["MESSAGE"]
如何获取包含的 text/html ?
最佳答案
最后调用get()
来获取数组。这些值将位于该数组中。
var ids = $('table input:checked').map(function(){
return $(this).closest('tr').find('td:eq(3)').text();
}).get();
否则,您只有一个指向一堆字符串的 jQuery 集合。
关于javascript - 如何在 javascript/jquery 中从 Object[value] 中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26791879/