未捕获的类型错误:无法读取未定义的属性“className" [英] Uncaught TypeError: Cannot read property 'className' of undefined

查看:35
本文介绍了未捕获的类型错误:无法读取未定义的属性“className"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Chrome 的开发者工具中抛出以下错误:

The following error is being thrown in Google Chrome's developers tools:

未捕获的类型错误:无法读取未定义的属性className"

Uncaught TypeError: Cannot read property 'className' of undefined

抛出错误的代码是:

var oTable = $('#resultstable').dataTable({
                            "bAutoWidth" : true,
                            "iDisplayLength" : 10,
                            "bFilter" : false,
                            "bLengthChange" : false
                        });

resultstable 是 html 中表格的 id:

resultstable is the id of a table in the html:

<table cellpadding="0" cellspacing="0" border="0" id="resultstable"
                    name="resultstable" class="display datatable">

奇怪的是在table标签之后有一个if语句.当程序被发送到 else if{} 部分时,表格运行得很好并且 CSS 正确显示,但是它抛出上述错误并且当它在 中时没有应用 CSSif{} 部分.

The weird thing is that after the table tag there is an if statement. The table runs perfectly fine and the CSS shows up correctly when the program is sent into the else if{} section, but it throws the above error and no CSS is applied when it is in the if{} section.

请帮忙!

推荐答案

另一个答案让我走上了正轨.

The other answer put me on the right track.

更简洁地说,错误是我创建的表不正确.

More succinctly, the error was that the table I was creating was incorrect.

我的标题列(当然在顶部)与我的行列(在 tbody 内)不匹配

My header columns (inside a thead of course), did not match up with my row columns (inside the tbody)

在我的情况下,标题中有太多列.

In my situation, I had too many columns inside the header.

这篇关于未捕获的类型错误:无法读取未定义的属性“className"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆