The break and continue functions of the jquery each function are fortunate to be another breakthrough and continue a jQuery loop. You can break the false loop in which the function returns a jQuery parameter. One can continue to execute but does not specify the return value or any other false return value.
Jquery each function break and continue Function
Fortunately, another breakthrough continues a jquery loop. You can break the false loop in which the function returns a jquery parameter. One can continue to execute but does not specify the return value or any other false return value.
$ ('. Iner'). each (function (I ){
If ($ (this). attr ('name') = "continue "){
Return; // implement the continue Function
} Else if ($ (this). attr ('name') = "break "){
Return false; // implement the break Function
}
})
Let's look at the jquery each function.
When you want to use return true in each to return the function to this function, you only need to let the each continue to execute
The each is not interrupted, so the function cannot return.
In jquery, each is very useful, except for the for loop that replaces webpage special effects.
Function methodone (){
....
$. Each (array, function (){
If (condition true ){
Return true;
}
});
....
}
Break continue instance
Continue: return true;
Break: return false;
Directly returning will also jump out of jquery.
Therefore, you can write the following code:
$ ('Lil'). each (function (index ){
If (index = 2) return true;
If (index = 4) return false;
Examples (this).css tutorial ("border", "1px red solid ");
});