Reputation: 5005
<label>Search: <input type="text" aria-controls="company"></label>
Using Datatables, how would i added a class to the search field input box?
Upvotes: 3
Views: 24268
Reputation: 2298
i'm use DataTable 1.10.x and Bootstrap :
$.extend($.fn.dataTableExt.oStdClasses, {
"sFilterInput": "form-control yourClass",
"sLengthSelect": "form-control yourClass"
});
I go through the extend function instead of jquery. :)
Upvotes: 7
Reputation: 14318
Depending which example are you using.. if you are using the following http://datatables.net/release-datatables/examples/basic_init/zero_config.html
$(document).ready(function() {
$('#example').dataTable();
$('#example_filter input').addClass('yourclass'); // <-- add this line
} );
P.S.: If the table have more input search or you have more tables, you can refer to all the input search by using the class selector
(".someClass")
Upvotes: 16
Reputation: 76890
I'd do
$('.dataTables_filter input').addClass('yourclass');
of course add this after you initialize your table
Upvotes: 8