dataTables assigning a css class to the pagination

2019-04-06 04:02发布

I have a dataTable with it most basic initialization code. But, I need to assign a custom pagination css class to the pagination which appears at the bottom of the table (i want to assign Twitter bootstrap pagination class). How should I do this?

Here is my code:

$(document).ready(function() {
                        /* Build the DataTable with third column using our custom sort functions */
                        $('#list_table').dataTable({"sPaginationType" : 'full_numbers', 'sPaging' : 'pagination'});

                    } );

2条回答
闹够了就滚
2楼-- · 2019-04-06 04:56

You can use drawCallback option:

$(document).ready(function () {
    $('#myDataTable').DataTable({
        ...
        "drawCallback": function () {
            $('.dataTables_paginate > .pagination').addClass('pagination-sm');
        }
    });
});
查看更多
劫难
3楼-- · 2019-04-06 05:02

use .addClass() method:

$('yourpager').addClass('yourTwitterbootstrappaginationclass');
查看更多
登录 后发表回答