jQuery中最接近IE的行为非常慢

我有一个5000行的表。 在每一行中我都有一个html元素。 myElementList是这些元素的列表。 现在我需要选择这些元素的所有tr。 我使用以下代码。

myElementList.closest('tr'); 

这项工作在FF很棒。 但是,当我在IE 8中运行相同时。浏览器挂起并出现一个弹出式杂乱的东西,用于停止脚本。

任何建议,为什么我看到这种行为或他们是任何替代。

编辑

当我使用parents()时,行为保持不变

  myElementList.parents('tr'); 

为了得到你想要的相当活泼(最接近每个复选复选框的父tr)你可以做这样的事情:

 $.fn.extend({ closestByTagName: function(tagname) { var tag = tagname.toUpperCase(), i = this.length, node, found=[], trParents; while(i--) { node = this[i]; while((node=node.parentNode) && node.nodeName != tag); if(node) { found[found.length] = node; } } return $(found); } }); var result = $('input:checked').closestByTagName('tr'); 

它不漂亮,但我想不出更快的方式。 (它应该大幅击败jQuery)

尝试使用parent(),child(),next(),prev()选择器。 我不是100%关于jQuery如何遍历表来查找tr但是5000行是很多遍历。 更具体的是使js引擎减少工作量。

http://api.jquery.com/category/traversing/

 $('input:checked').parent('tr').each(function(i){....