Home > Web Front-end > JS Tutorial > Jquery each method jumps out of the loop and gets the return value (explanation with examples)_jquery

Jquery each method jumps out of the loop and gets the return value (explanation with examples)_jquery

WBOY
Release: 2016-05-16 17:09:35
Original
1430 people have browsed it
return false: will stop the loop (just like using 'break' in a normal loop).
return true: Jump to the next loop (just like using 'continue' in a normal loop).
Copy code The code is as follows:

function test(){
var success = false ;
$(..).each(function () {
if (..) {
success = true;
return false;
}
});
return success ;
}

jquery is an object chain, so $(..).each() still returns a collection of objects. each(function(){}): It is a callback function. In the callback function, the result cannot be returned outside the callback function each.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template