【问题标题】:Uncaught TypeError: Cannot read property 'className' of undefined for datatable未捕获的类型错误:无法读取数据表未定义的属性“类名”
【发布时间】:2016-02-12 19:26:19
【问题描述】:

我的表有以下代码class="table table-striped table-bordered bootstrap-datatable datatable datatable" 我想使用数据表功能,如搜索、分页等。因此我在类列表中添加了数据表。

我还提供了指向<script src='js/jquery.dataTables.min.js'></script> 的链接 但我得到这个错误。它缺少哪个类名如何添加? Uncaught TypeError: Cannot read property 'className' of undefined and it points 到 .js 文件中的这一行。

(n.className+=" "+m.sClass),k?d._anHidden[g]=null:(d._anHidden[g]=n,n.parentNode.removeChild(n)),m.fnCreatedCell&&m.fnCreatedCell.call(a.oInstance,n,w(a,b,g,"display"),d._aData,b,g)}}if(0!==a.aoRowCreatedCallback.length){b=0;for(c=a.aoData.length;b<c;b++)d=a.aoData[b],C(a,"aoRowCreatedCallback",null,[d.nTr,d._aData,b])}}function K(a,b){return b._DT_RowIndex!==n?b._DT_RowIndex:null}function da(a,b,c){for(var b=L(a,b),d=0,a=a.aoColumns.length;d<a;d++)if(b[d]===c)return d;

目前这是我的表结构的样子

<div class="box-content">
                            <table class="table table-striped table-bordered bootstrap-datatable datatable datatable" style='table-layout: fixed;'>
                          <thead>
                              <tr>
                                  <th style='width: 10%;'>No.</th>
                                  <th style='width: 35%;'>Name</th> 
                                  <th style='width: 25%;'>Contact Number</th>                                
                                  <th style='width: 20%;'>Stats</th>
                              </tr>
                          </thead>  

【问题讨论】:

    标签: javascript jquery css twitter-bootstrap datatable


    【解决方案1】:

    您确定在执行此脚本之前该页面已加载给定的类名吗?换句话说,尝试将此脚本放在页面底部,以验证它没有在 DOM 加载之前加载。

    【讨论】:

    • 在执行这个脚本之前我没有得到你的类名?是的,它在页面底部的 javascript 是我称之为的地方。
    • 你能用你的 html 中的表结构更新你的问题,以及你是如何为数据表执行 javascript 的吗?
    • 嗨,我已经用我的 html 中的表结构更新了我的问题。这是正确的吗?
    • 你有一个结束的 标签,对吧?我也假设你正在使用这个插件? datatables.net
    • 是的,我有关闭表,下面是长 php 代码,这就是我省略它的原因。目前我在一个选择查询下运行并手动填充我的表。是的,我正在尝试使用 datatables.net
    猜你喜欢
    • 1970-01-01
    • 2012-06-28
    • 1970-01-01
    • 2021-12-22
    • 1970-01-01
    • 2013-05-29
    • 1970-01-01
    • 1970-01-01
    • 2018-03-10
    相关资源
    最近更新 更多