简体   繁体   中英

Jquery Datatables:set the class on the filter input field

How can I set the class on the 'search' field on the datatables plugin please. I'm using the Jquery UI theme as well.

        $('#idSmovData').dataTable( {
             "sScrollY": "600px"
            ,"bPaginate": false
            ,"bFilter": true
            ,"bJQueryUI": true
            ,"bInfo": false
            ,"bSort": false
        });

You can set the search filter wrapper div style class using oStdClasses

$.fn.dataTableExt.oStdClasses["sFilter"] = "my-style-class";

And than use regular css to target the search input field:

.my-style-class input[type=text] {
     color: green;
}

Please refer to the datatables styling section for more details.

$('div.dataTables_filter input').addClass('form-control');
$('div.dataTables_length select').addClass('form-control');

Here I am adding the Bootstrap class form-control to the filter input and the length select, as an example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM