How do I break out of an $.each in jquery?

后端 未结 6 1289
抹茶落季
抹茶落季 2020-12-18 14:45

How to I break out of the following jquery each method when a condition is met;

var rainbow = {\'first\' : \'red\', \'second\' : \'orange\',         


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-18 15:11

    As explicitly written on jQuery's page for $.each :

    We can break the $.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.

    Please google the terms you search before posting here ! It's a pity that jQuery has one of the best documentations ever if you do not bother to read about it !

提交回复
热议问题