如何在jQuery DataTable中动态显示表头

时间:2018-08-13 18:20:46

标签: jquery database

我有一个来自jquery datatable插件的表,其数据来自外部json。在这里,我还需要从json动态获取列标题()数据,现在它来自static。它需要添加/修改因为我已经在项目中使用过该代码,所以结构相同。下面是我的代码。任何人都可以帮我。谢谢

HTML

rfid

Script.js

rfid

1.json

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="script.js"></script>
<div id="div">
<div>
 <table id="example">
        <thead>
            <tr>            
                <th>name</th>
                <th>stargazerscount</th>
                <th>forkscount</th>
                <th>description</th>               
            </tr>
        </thead>
        <tbody>          
        </tbody>
    </table>

    </div>  
</div>  

0 个答案:

没有答案