How to use continue in jQuery each() loop?

后端 未结 4 1673
悲&欢浪女
悲&欢浪女 2021-01-29 20:13

In my application i am using AJAX call. I want to use break and continue in this jQuery loop.

$(\'.submit\').filter(\':checked\').each         


        
4条回答
  •  爱一瞬间的悲伤
    2021-01-29 20:27

    We can break both a $(selector).each() loop and a $.each() loop at a particular iteration by making the callback function return false. Returning non-false is the same as a continue statement in a for loop; it will skip immediately to the next iteration.

    return false; // this is equivalent of 'break' for jQuery loop
    
    return;       // this is equivalent of 'continue' for jQuery loop
    

    Note that $(selector).each() and $.each() are different functions.

    References:

    • $(selector).each()
    • $.each()
    • What is the difference between $.each(selector) and $(selector).each()

提交回复
热议问题