【发布时间】:2011-12-18 14:06:05
【问题描述】:
我有功能:
function doBlamingItem($cell, showEditMark) {
$cell.hover(function () {
$cell.toggleClass('clickable-cell', showEditMark).toggleClass('editing-cell', !showEditMark);
}, function() {
$cell.removeClass('clickable-cell editing-cell');
} );};
在 $(document).ready() 中,我将此函数应用于表中的某些单元格(~500),当我将鼠标移到它上面时 - 在 FF 或 Chrome 中一切正常,但 IE7-9 开始滞后并且我不知道如何解决它:(
以及来自 $(document).ready() 的代码:
var i = firstRowOnPage();
while (table.GetRow(i) != null) {
if (condition) {
var row = table.GetRow(i);
var elementInCellId = column.fieldName + '_' + rowKey;
var $cell = $(row.cells[realIndex]).attr('id',elementInCellId);
doBlamingItem($cell, true);
setClickable(editInfo, $cell);
}
i++;
}
我对每个单元格都使用 doBlamingItem,因为其中一些为 showEditMark=true,而另一些为 showEditMark=false
【问题讨论】:
-
对不起,我帮不上忙,但我想说的是,至少在这个问题上,你的英语看起来并不糟糕 :)
-
你确定没有对每个元素应用 500 个事件处理程序吗?!
-
请显示调用此函数的代码。
-
意识到 IE 仍然比竞争对手慢一点。此外,表格在 html-dom 世界中非常特殊。 this jsperf test case 是一个很好的例子(在 jsperf 上的大量其他案例中)
标签: javascript jquery internet-explorer jquery-selectors