Latest Tweets:
I'm a web applications developer living in Austin, TX.
Curious mind with a passion for web development and surrounding topics. Also interested in science, triathlons, and travel.
Enrique Delgado Monroy
If you ever tried to use Javascript’s ‘break’ and ‘continue’ keywords within a jQuery each loop, you probably got a sytax error.
The ‘break’ and continue ‘keywords’ do not make sense in the context of a jQuery each loop, but you can use ‘return true’ or ‘return false’ within your loop to simulate continue and break respectively.
stevenbs put it well here:
To do a continue, at any point inside the function “return true” will simulate the same behavior as continue (that is, it will stop execution of everything else in the function, and go to the next item in the list).
To do a break, “return false”. That will simulate a break (That is, no more code in the loop will run…it will not go to the next item in the list)