javascript datatables.net 添加一个类到搜索标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9922040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
datatables.net add a class to the search label
提问by ahmet
<label>Search: <input type="text" aria-controls="company"></label>
Using Datatables, how would i added a class to the search field input box?
使用Datatables,我将如何向搜索字段输入框添加一个类?
回答by antonjs
Depending which example are you using.. if you are using the following http://datatables.net/release-datatables/examples/basic_init/zero_config.html
取决于您使用的是哪个示例.. 如果您使用以下 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")
PS:如果表有更多的输入搜索或者你有更多的表,可以使用 class selector
(".someClass")
回答by Breith
i'm use DataTable 1.10.x and Bootstrap :
我正在使用 DataTable 1.10.x 和 Bootstrap :
$.extend($.fn.dataTableExt.oStdClasses, {
"sFilterInput": "form-control yourClass",
"sLengthSelect": "form-control yourClass"
});
I go through the extend function instead of jquery. :)
我通过扩展函数而不是 jquery。:)
回答by Nicola Peluchetti
I'd do
我会做
$('.dataTables_filter input').addClass('yourclass');
of course add this after you initialize your table
当然在你初始化你的表后添加这个