小编Jam*_* D.的帖子

单击数据表中的单元格时获取列和行名称

我使用datatables(http://datatables.net/)来创建带有JSON的表,我有一个代码:

<script type="text/javascript">
$(document).ready(function() {
    $('#example').dataTable( {
        "ajax": "objects.txt",
        "columns": [
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "extn" },
            { "data": "start_date" },
            { "data": "salary" }
        ]
    } );
} );
</script>
<div class="container">
<table id="example" class="table table-striped table-bordered table-responsitive" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>DAN</th>
                <th>Aktivnost</th>
                <th>Vreme</th>
                <th>Rashodi</th>
                <th>Prihodi</th>
                <th>Beleske</th>
            </tr>
        </thead>

        <tfoot>
            <tr>
                <th>DAN</th>
                <th>Aktivnost</th>
                <th>Vreme</th>
                <th>Rashodi</th>
                <th>Prihodi</th>
                <th>Beleske</th>
            </tr>
        </tfoot>
    </table>
    </div>
Run Code Online (Sandbox Code Playgroud)

当我点击某个单元格时,如何获取行的名称和列的名称?另外,当点击表格中的某个单元格时,如何获取行的ID和列的ID?

javascript datatable jquery

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

datatable ×1

javascript ×1

jquery ×1