以下函數需要至少3秒才能運行(在500個錶行上)。是否有可能使此功能更快?功能很慢,有沒有更快的方法? (使用jQuery 1.4.2)
function prepareTable() {
var groupIndex = 0;
$("#row tbody tr").each(function(index) {
// each row gets a unique id
// remove default css styles for table rows
// read out hidden value, that stores if row is a group
var group = $(this).attr('id', 'node-'+index).removeClass("odd event").find('td :hidden').attr('value');
// if it is a group, add special styles to row and remember row index
if (group == 'true') {
groupIndex = index;
$(this).addClass('odd').find("td:first")
.mouseenter(function() {
$(this).parent().addClass("swGroupLink");
})
.mouseleave(function() {
$(this).parent().removeClass("swGroupLink");
});
} else {
// make all following rows to children of the previous group found
$(this).addClass('even child-of-node-' + groupIndex);
}
});
}
全部500個錶行是可見的,還是你使用分頁? – 2010-08-23 07:00:55
我也在使用分頁。 thx的提示... – Steven 2010-08-23 07:18:57
然後你可以做只處理表的可見部分。 – 2010-08-23 07:29:37