dataTables assigning a css class to the pagination

2019-04-06 04:09发布

问题:

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'});

                    } );

回答1:

You can use drawCallback option:

$(document).ready(function () {
    $('#myDataTable').DataTable({
        ...
        "drawCallback": function () {
            $('.dataTables_paginate > .pagination').addClass('pagination-sm');
        }
    });
});


回答2:

use .addClass() method:

$('yourpager').addClass('yourTwitterbootstrappaginationclass');