html table has 4 levels of hierarchy in a tree type view. To give user a control to expand/collapse to any level, the following function is used. But this function takes more than 6 seconds to execute on IE8. It takes half of that time in Chrome. Any suggestions for how to speed this function up? Thanks
function showDetailLevel(level) {
/*hide all the tr*/
$('.dataRow').each(function() {
$(this).hide();
});
/*collapse all the carets*/
$('.detailsCarat').each(function() {
if ($(this).hasClass('ui-icon-triangle-1-s')) {
$(this).removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');
}
});
/*show the rows and expand all the carets that are at a tree level above the selected level*/
for (var i=1; i<=level;i++) {
$('.detailLevel'+i).each(function() {
$(this).show();
if (i<level) {
$(this).find('span.ui-icon-triangle-1-e').removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');
}
});
}
}