jQuery DataTables:如何更改分页活动颜色?

我正在使用jQuery DataTables插件,并希望更改分页的颜色.

使用CSS我想改变字体颜色,悬停字体颜色和活动页面颜色.

分页代码如下所示:

<script>
$(document).ready(function() {
    $.fn.dataTable.ext.errMode = 'none';
     var table = $('#users').DataTable({
     "columnDefs": [
        { "visible": false, "targets": 1 }
      ],
     "columns": [
        { "data": "user"},
        { "data": "name"}
    ],

    "processing": true,
    "serverSide": true,
     "searching": true,
     "paging": true,

    "ajax": {
       url: "get_info.php",
       type: 'POST'

       },
    "order": [[ 2, 'asc' ]],
     "lengthMenu": [
        [25, 50, 100],
        [25, 50, 100]
      ],
     "iDisplayLength": 20,

    "drawCallback": function ( settings ) {
        var api = this.api();
        var rows = api.rows( {page:'current'} ).nodes();
        var last=null;

        api.column(1, {page:'current'} ).data().each( function ( group, i ) {
            if ( last !== group ) {
                $(rows).eq( i ).before(
                    '<tr class="group"><td colspan="8">'+group+'</td></tr>'
                );

                last = group;
            }
        } );
    }
} );

// Order by the grouping
$('#devices tbody').on( 'click', 'tr.group', function () {
    var currentOrder = table.order()[0];
    if ( currentOrder[0] === 2 && currentOrder[1] === 'asc' ) {
        table.order( [ 2, 'desc' ] ).draw();
    }
    else {
        table.order( [ 2, 'asc' ] ).draw();
    }
  } );
} );

</script>

                  

                <tr>
                  <th>user</th>

                  <th>name</th>

                </tr>
              </thead>
              <tfoot>
                <tr>
                  <th>user</th>

                  <th>name</th>

                </tr>
              </tfoot>
            </table>

感谢您对此的任何帮助,

最佳答案 您需要为分页链接按钮设置样式的类:

>“paginate_button” – 所有分页按钮都有此类
>“current” – 除了上面的类之外,它还标记了当前页面的按钮.

因此,您可以在datatables css文件之后包含一个css文件,并带有以下覆盖:

a.paginate_button {
    // override font-color here.
}
a.paginate_button:hover {
    // override hover font-color here.
}
a.paginate_button.current {
    // override current page button styling here.
}
点赞