例如:
> function foo() {
> jQuery(whatever).each( function() {
return; // this just exits the anonymous function - is there a way to return from foo?
}
);
>
> }
Run Code Online (Sandbox Code Playgroud)
Lee*_*Lee 11
**更正:添加更多细节.使用标志允许从PARENT函数返回**
function foo() {
var doreturn = false;
jQuery(whatever).each( function() {
if(youwanttoreturn){
doreturn=1;
return false;
}
});
if(doreturn)return;
}
Run Code Online (Sandbox Code Playgroud)
http://api.jquery.com/each/ "我们可以通过返回false来停止回调函数中的循环."
| 归档时间: |
|
| 查看次数: |
3859 次 |
| 最近记录: |