$.each当条件满足时,如何退出循环?我不想再进一步迭代这个集合.
$(vehicles).each(function() {
if (this["@id"] === vehicleId[0]) {
vehicle = this;
}
});
Run Code Online (Sandbox Code Playgroud)
我尝试使用break;&return;语句,但它看起来执行并不会在那时停止.任何想法将不胜感激.
Joe*_* C. 15
返回false相当于突破$ .each循环.所以在你的例子中:
if (this["@id"] === vehicleId[0]) { vehicle = this; return false; }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9288 次 |
| 最近记录: |