gpt4 book ai didi

javascript - 在 IE 中将表解析为数组对象的有效方法

转载 作者:行者123 更新时间:2023-11-28 10:13:26 24 4
gpt4 key购买 nike

我的表有超过 1k 行和超过 7 列,试图解析为数组对象,我尝试使用 jquery

$(tableSearch).each(function () {
$('tr', $(this)).each(function (key, tr) {
var self = this;
var obj = new Object();
var rowPos = 0;
$('td', tr).each(function (rowPos) {
obj[_self.colModel[rowPos].name] = $(this).html();
});
obj['Key'] = 'Rec-' + key;
});
});

在 FF 中需要 300 毫秒,但在 IE 中需要 60 秒:(

你可以比较一下它的速度慢了大约 200 倍。

有什么办法可以提高 IE 的性能吗?我尝试了原始的javascript方法,在IE中仍然没有达到效率。

帮助我!!!!!!...我怎样才能在所有浏览器中获得相似的性能。

提前致谢

最佳答案

我得到了解决方案,如果我们这样实现,IE 会更快

table = document.getElementById("myGrid");
for (i = 0; i < table.rows.length; i += 1) {
var rowData = new Array();
row = table.rows[i];
for (j = 0; j < row.cells.length; j += 1) {
cell = row.cells[j];
rowData[j] = cell.innerHtml
}
obj.push(rowData);
}

注意:如果您使用任何调试器,请禁用 Debug模式。

那么IE似乎还可以,但不可能比FF或safari快

关于javascript - 在 IE 中将表解析为数组对象的有效方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7078350/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com