ÍøÂçѧԺ

w3pop.com :: ÍøÂçѧԺ :: JavaScript :: JS Break Ñ­»·

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

JavaScript
JSÊýѧ¶ÔÏó²Î¿¼
JS×Ö·û´®¶ÔÏó²Î¿¼
JSº¯Êý²Î¿¼
JSʼþ²Î¿¼
Javascript ³£ÓÃÕ..
FFºÍIEϵÄjs¼æÈÝ..
jQuery ¼òµ¥½éÉÜ
jQuery / ºËÐÄ / ..
jQuery / ºËÐÄ / ..
ÈçºÎʹÓÃJSÀ´ÅжÏ..
JavascriptÔÚIEºÍ..
3¸öjs×Ö·û±àÂ뺯Ê..
javascript ÖÐµÄ ..

JS Break Ñ­»·


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ä¯ÀÀ:13933 :: ::

There are two special statements that can be used inside loops: break and continue.
breakºÍcontinueÊÇÁ½¸öÓÃÔÚÄÚ²¿Ñ­»·µÄÌØÊâÓï¾ä¡£


Examples
¾ÙÀý

Break statement
Use the break statement to break the loop.
ʹÓÃbreakÓï¾äÌø³öÑ­»·

Continue statement
Use the continue statement to break the current loop and continue with the next value.
ÓÃcontinueÓï¾äÀ´Ìø³öµ±Ç°µÄÑ­»·¼ÌÐøÏÂÃæµÄÖµ


JavaScript break and continue Statements
JSµÄbreakºÍcontinueÓï¾ä

There are two special statements that can be used inside loops: break and continue.
breakºÍcontinueÊÇÁ½¸öÓÃÔÚÄÚ²¿Ñ­»·µÄÌØÊâÓï¾ä¡££¨ºÍµÚÒ»¾äÖØ¸´ÁË-_-£©

Break
Ìø³ö£¨Ò²¿ÉÒÔÀí½âΪÀ뿪£©

The break command will break the loop and continue executing the code that follows after the loop (if any).
breakÃüÁî»áÀ뿪µ±Ç°µÄÑ­»·²¢½Ó×Å¿ªÊ¼Ö´ÐÐÏÂÃæµÄÑ­»·£¨Èç¹ûÓеϰ£©

Example
Àý×Ó

<html>

<body>
<script type="text/javascript">
var i=0
for (i=0;i<=10;i++)
{
if (i==3){break}
document.write("The number is " + i)
document.write("<br />")
}
</script>
</body>
</html>

Result
½á¹û

The number is 0
The number is 1
The number is 2

Continue
¼ÌÐø

The continue command will break the current loop and continue with the next value.
continueÃüÁî»áÌø³öµ±Ç°µÄÑ­»·²¢¼ÌÐøÏÂÃæµÄÖµ

Example
Àý×Ó

<html>

<body>
<script type="text/javascript">
var i=0
for (i=0;i<=10;i++)
{
if (i==3){continue}
document.write("The number is " + i)
document.write("<br />")
}
</script>
</body>
</html>

Result
½á¹û

The number is 0
The number is 1
The number is 2
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
The number is 10

ÆÀÂÛ (0) All