Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript table.rows.length在IE11中不起作用_Javascript_Html - Fatal编程技术网

Javascript table.rows.length在IE11中不起作用

Javascript table.rows.length在IE11中不起作用,javascript,html,Javascript,Html,我的html页面中有下面的脚本 var table = document.getElementById(tableID); var rowCount = table.rows.length; 它在IE8中工作正常。但当我使用IE11时,它并没有返回准确的行。相反,它只是返回0。但实际行大小是1 要使其正常工作,需要替换哪些代码。鉴于对table元素的引用,最简单的方法是使用querySelectorAll在tbody中查找tr: window.onload=函数{ var table=doc

我的html页面中有下面的脚本

var table = document.getElementById(tableID);
var rowCount = table.rows.length;
它在IE8中工作正常。但当我使用IE11时,它并没有返回准确的行。相反,它只是返回0。但实际行大小是1


要使其正常工作,需要替换哪些代码。

鉴于对table元素的引用,最简单的方法是使用querySelectorAll在tbody中查找tr:

window.onload=函数{ var table=document.getElementByIdtbl; console.logtable.querySelectorAlltbody tr.length; } 第1行 第2行 第3行