Exit the loop in js and jquery and proceed to the next loop

  • 2020-03-30 03:49:20
  • OfStack

As parallel goods, is learned 1+1=3 also want to record! No, it's 2

Learning record:

The js


for(var i=1;i<5;i++){
if(i==3){
break; //Use break to pop up two prompts as 1,2; If you use continue, it pops up three times, 1,2,4
}
alert(i);
}

Loop, exit the loop, use break; Exit the current loop to continue with the next loop, using continue

To implement break in jquery's each() method, use return false; Continue, using return true


Related articles: