I stumbled upon a strange behaviour while using jQuery + dataTables plugin.
Let's say I have the following table:
<table id="myTable">
<thead>
<th>col 0</th>
<th>col 1</th>
</thead>
<tbody>
<tr>
<td><input type="checkbox" /></td>
...
</tr>
...
</tbody>
</table>
I call $('#myTable').dataTable({...});
on document.ready and want to get all rows that have checked inputs when I click a button (even if they are not on the current page of the table).
To get all rows (including unchecked) I use $('#myTable').dataTable().fnGetNodes()
(API-Link) which returns an array with all those tr-nodes. After that I use this array to construct a jQuery-object:
var nodearray = $('#myTable').dataTable().fnGetNodes();
var trs = $(nodearray);
Here comes the part I don't understand. I tried two ways to get all checked nodes but the results were different:
// returns all rows correctly (including invisible rows from other pages)
trs.find('td input:checked').closest('tr');
// return only rows from the current page
trs.has('td input:checked');
What does the DataTables-plugin do to hide rows so that jQuery.has() doesn't find them and why does jQuery.find() still work though?
PS: I created a simple fiddle here