Jquery Datatables:在过滤器输入字段上设置类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9486954/
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
Jquery Datatables:set the class on the filter input field
提问by Keith
How can I set the class on the 'search' field on the datatables plugin please. I'm using the Jquery UI theme as well.
请如何在数据表插件的“搜索”字段上设置类。我也在使用 Jquery UI 主题。
$('#idSmovData').dataTable( {
"sScrollY": "600px"
,"bPaginate": false
,"bFilter": true
,"bJQueryUI": true
,"bInfo": false
,"bSort": false
});
采纳答案by Maxim Manco
You can set the search filter wrapper div style class using oStdClasses
您可以使用设置搜索过滤器包装 div 样式类 oStdClasses
$.fn.dataTableExt.oStdClasses["sFilter"] = "my-style-class";
And than use regular css to target the search input field:
而不是使用常规 css 来定位搜索输入字段:
.my-style-class input[type=text] {
color: green;
}
Please refer to the datatables stylingsection for more details.
有关更多详细信息,请参阅数据表样式部分。
回答by mpdc
$('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.
在这里,我将 Bootstrap 类添加form-control
到过滤器输入和长度选择中,作为示例。