How to skip to next iteration in jQuery.each() util?
2017-08-23 14:33
423 查看
[问]
I'm trying to iterate through an array of elements. jQuery's documentation says:
jquery.Each() documentation
Returning non-false is the same as a continue statement in a for loop, it will skip immediately to the next iteration.
I've tried calling 'return non-false;' and 'non-false;' (sans return) neither of which skip to the next iteration. Instead, they break the loop. What am i missing?
【答】
What they mean by non-false is:
return
true;
So this code:
var arr = [ "one", "two", "three", "four", "five" ];
$.each(arr, function(i) {
if(arr[i] == 'three') {
return
true;
}
alert(arr[i]);
});
Will alert one, two, four, five
From: https://stackoverflow.com/questions/481601/how-to-skip-to-next-iteration-in-jquery-each-util
相关文章推荐
- 如何使用th:each属性迭代模板-原标题:How To Use th:each For Iteration In Thymeleaf Template?
- csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net C
- How to find TOP 3 in each group?
- csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net
- as3corelib Tutorial:How to Use ArrayUtil Class in Flex
- Axure RP Pro - jQuery - How to implement fade in and fade out effects
- How to make an image move in a circular path using jquery?
- How to retrieve checkboxes values in jQuery
- How to use next and last in Perl
- Junit: How to skip a test case in Junit ?
- recursion - How to write a simple preorder DOM tree traversal algorithm in jQuery? - Stack Overflow
- How to solve “jQuery not working in AJAX loaded elements”
- How to update jQuery Mobile in Dreamweaver CS6
- Junit: How to skip a test case in Junit ?
- How to update jQuery Mobile in Dreamweaver CS6
- How to write plugin in Jquery.
- How to increment version information after each build in Visual C++
- Populating Next Right Pointers in Each Node I,II,Add Two Numbers,Integer to Roman
- How to skip other publishable projects during publish a clickonce project in a solution?
- Here's an example that shows how to enumerate through the features of a selection set, returning the value of each field in the attribute table except for the geometry colum.