jQuery Datatables元素放置

时间:2016-08-12 18:11:45

标签: jquery html css datatables

我正在使用jQuery Datatables的页面,我正在试图弄清楚如何在标记中放置一个元素。

这是页面:

enter image description here

我希望“点击此处下载完整报告”链接,在“资金摘要”标题的同一行右侧对齐。

以下是我用来添加标题的代码:

$(document).ready(function () {

   var FStable = $('#tblFundingSummary').dataTable(
       {
           "scrollY": "300px",
           "scrollCollapse": true,
           "paging": false,

           dom: '<"toolbar">rti<"floatRight"B><"clear">',

           buttons: {
               buttons: [
                   { extend: 'excel', text: 'Export to Excel', exportOption: { page: 'current' }, footer: true }
               ]
           }

       });

   $("#tblFundingSummary_wrapper div.toolbar").html('<h2>Funding Summary</h2><div style="text-align: right; float:right;"><a id="aExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel"  runat="server">Click here to download full report</a></div>');

1 个答案:

答案 0 :(得分:0)

由于您要通过代码添加标题和按钮,因此可以将<h2>标记为display:inline-blockfloat:left或任何其他符合您要求的css设置

$("#tblFundingSummary_wrapper div.toolbar")
     .html('<h2 style="display: inline-block;">Funding Summary</h2><div style="text-align: right; float:right;"><a id="aExport" title="Click here to download full report" OnServerClick="ExportFundingSummaryToExcel"  runat="server">Click here to download full report</a></div>');