Home > Article > Web Front-end > Detailed explanation of basic usage examples of jquery's each loop
Common loop statements in javascript are: whileloop do whileloop and forLoop . All three types of loop statements have their own advantages.
1. While loop Format As follows: ## while (condition){ Code that needs to be executed } document.write("Here is the input of 1-50 printed by while:"); var i = 1; while(i25cad3546873fef9dd6cd121c0cd60f82--->4-->3 When does the for loop end: When the logical judgment is false (false), This terminates the cycle. Example: Print from 1 to 100; for(var i=1;i<=100;i++){ document.wirter(" "+i) } ##The difference between the three is demonstrated by a small case: do{ ##document.write("Will this be entered into the page?");}while(1==2); for(var i=1;i==2;i++){ document .write("Will for be entered into the page here?"); } while(i==2){ document.write("While will this be input to the page?"); } Proved by actual practice: the content in the do while statement will be output directly.
Summary: The difference between for loop while loop do while loop is that: do while will execute the loop body once regardless of whether the logical conditions are met, while while and for But it won't. Attached jquery each() loop-try it yourself
|
The above is the detailed content of Detailed explanation of basic usage examples of jquery's each loop. For more information, please follow other related articles on the PHP Chinese website!