$()
Perform a jQuery selection action on the full table.
Description
DataTables makes heavy use of DOM manipulation, removing rows from the document for paging and searching, and removing columns from the document for column visibility, among other actions. jQuery will not find these removed DOM elements when using a standard jQuery statement since it uses the document as the root element and some nodes under DataTables' control have been removed from the document.
To provide an easy method to continue using jQuery on these elements, so you can select elements regardless of searching, paging or any other feature of DataTables this method is provided.
The selector given to the $()
method will be run on all of the tr
elements in the table, and their descendent elements, with the found elements being returned as a jQuery object.
Type
function $( selector [, modifier ] )
- Description:
Perform a jQuery selector on the rows and contents of the rows in the tables'
tbody
elements.- Parameters:
Name Type Optional 1 selector
No jQuery selector to perform on the nodes inside the table's tbody tag.
2 modifier
Yes - default: Option used to specify how the content's of the selected columns should be ordered, and if paging or filtering in the table should be taken into account. This is only useful for operations which involve rows, such as
column().nodes()
andcolumn().data()
.- Returns:
jQuery object with the matched elements in its result set.
Example
Find all cells with content's 'High' and add a class:
var table = new DataTable('#myTable');
table.$(':contains("High")').addClass('important');