【发布时间】:2014-07-18 17:18:04
【问题描述】:
我想知道是否有一种性能良好的方法来确定.nextUntil() 是否在未匹配指定选择器的情况下停止。
如果选择器不匹配任何元素,.nextUntil() 将返回与 .nextAll() 相同的结果。
所以可以使用:
if ($("#id").nextUntil(".someclass").length === $("#id").nextAll().length) {
//do some stuff if there was no match
}
但是有更好的解决方案吗?
【问题讨论】:
-
你已经有一个错字
nextUnil...所以它可能不匹配任何东西:D
标签: javascript jquery performance nextuntil