datatables add class to filters

前端 未结 3 1863
北荒
北荒 2020-12-30 08:03

I am currently seeking a method to add an additional custom class to the jQuery datatables filters (Records per page and Search)

Th

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 08:05

    Check out http://legacy.datatables.net/styling/custom_classes. DataTables has a slightly complicated way to override the CSS classes for some of the core elements. Here's one way

    $(document).ready(function() {
        var extensions = {
            "sFilter": "dataTables_filter custom_filter_class",
            "sLength": "dataTables_length custom_length_class"
        }
        // Used when bJQueryUI is false
        $.extend($.fn.dataTableExt.oStdClasses, extensions);
        // Used when bJQueryUI is true
        $.extend($.fn.dataTableExt.oJUIClasses, extensions);
        $('#example').dataTable();
    });
    

    Check out a working example here: http://jsfiddle.net/k2ava/3/.

提交回复
热议问题