Jquery nextUntil()替代

我有以下代码,这是尼克在之前的一个问题中提供的 ,它就像一个梦想。

我在想什么

“我正在尝试生成一个jquery脚本,以便使用类顶部的表格中的所有tr元素进行拼接,并且当使用类bt点击下面的所有tr时,使用类顶部的一个tr,直到有另一个tr类顶部将slideToggle。”

但是我确实必须在某些表中的top和bt类之间添加一个额外的行,这会破坏这些表中的jquery。

我想知道是否有任何修改,我不需要更改表中的代码,它仍然适用于所有应用的网页上的所有表。

     JS Bin   $("tr.top").click(function () { $(this).nextUntil('tr:not(.bt)').animate({ opacity: "toggle" }); });    
Click here to collapse the next tr with class bt but no other top row 1 top row 1
This is not ment to collapse when the tr at the top is clicked
bt row 1 bt row 1 bt row 1
bt row 1 bt row 1 bt row 1
bt row 1 bt row 1 bt row 1
Click here to collapse the next tr with class bt top row 2 top row 2
bt row 2 bt row 2 bt row 2
bt row 1 bt row 1 bt row 1
Click here to collapse the next tr with class bt top row 2 top row 2
bt row 2 bt row 2 bt row 2
bt row 1 bt row 1 bt row 1
​​​​​

你可以在这里看到例子

如果它不是.bt

 $("tr.top").click(function () { if (!$(this).next().hasClass('bt')) $(this).next().nextUntil('tr:not(.bt)').animate({ opacity: "toggle" }); else $(this).nextUntil('tr:not(.bt)').animate({ opacity: "toggle" }); }); 

(它有效,已经尝试过了)

嗯,它有点凌乱,但我认为这应该做的工作:

 $(this).nextAll('.bt:first').prev().nextUntil('tr:not(.bt)').animate({ opacity: "toggle" }); 

请参阅: http : //jsbin.com/ateze5/9