dom()
Perform a query 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. As such, simply using document.querySelector to pick elements will not find these removed DOM elements.
To provide an easy method to perform selectors 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 dom() 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 DataTable.Dom object.
Type
$( selector [, modifier ] )
Perform a CSS query selection on the rows and contents of the rows in the tables' tbody elements.
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | selector | No | |
CSS query selector to perform on the nodes inside the table's | |||
| 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 | |||
Returns:
DataTable.Dom: Dom object with the matched elements in its result set.
Example
Find all cells with a specific class and add another class:
var table = new DataTable('#myTable');
table.dom('.myClass').classAdd('important');