用jquery class去获取对象的属性,在firefox,ie9下面都没有问题,但是在ie8,ie6中会很慢,报出卡着的异常。
将这些东西从循环体中拿出来,问题得到解决,所以代码不管任何时候,执行一次能得到的结果,没必要执行多次。
一堆变量原本是写在方法filterMatchTr里面。
function filterTeamMatch() { var sRoundType = $('.css_con_round.ca_focus:first').text(); var sType = $('.css_con_type.ca_focus:first').text(); var sWinLose = $('.css_con_win_lose.ca_focus:first').text(); var sScoreDiff = $('.css_con_score_diff.ca_focus:first').text(); var sEuropDiff = $('.css_con_europ_diff.ca_focus:first').text(); var sTotal = $('.css_con_total.ca_focus:first').text(); var sJcTotal = $('.css_con_jc_total.ca_focus:first').text(); var sJcLet = $('.css_con_jc_let.ca_focus:first').text(); var teamId = $('.css_team_a.ca_focus:first').attr('teamId'); var showCount = 0; $('#jq_match_tbody tr').each(function(){ if (filterMatchTr($(this), sRoundType, sType, sWinLose, sScoreDiff, sEuropDiff, sTotal, sJcTotal, sJcLet, teamId)) { $(this).show(); showCount++; } else { $(this).hide(); } }); if (showCount == 0) { $('#jq_no_data_tr').show(); } else { $('#jq_no_data_tr').hide(); } }