将列过滤器显示为标头中的第二行

时间:2016-08-05 15:27:25

标签: jquery datatables

我使用此代码在页脚中显示列过滤器,效果很好,请参阅https://www.datatables.net/examples/api/multi_filter.html

我的代码是:

$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('#example tfoot th').each( function () {
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );

    // DataTable
    var table = $('#example').DataTable();

    // Apply the search
    table.columns().every( function () {
        var that = this;

        $( 'input', this.footer() ).on( 'keyup change', function () {
            if ( that.search() !== this.value ) {
                that
                    .search( this.value )
                    .draw();
            }
        } );
    } );
} );

问题是我希望过滤器位于标题下方而不是页脚。我尝试使用css更改tfoot标记的位置,但它在IE上没有用。

0 个答案:

没有答案
相关问题