·  JavaScript – Syntax – Conditional Statements – switch...case

 

- Info:

  - This tutorial shows how to use case conditional statements.

 

- Example:

  - Create D\Temp\JavaScript\Test.html

 

    Test.html   

    <script type="text/javascript" language="javascript">

      

      a = 5;

      switch (a) {

        case 1:

          window.alert("Value is 1. Exit from switch.");

          break;

        case 5:

          window.alert("Value is 5. Continue to next case or default.");

        default:

          window.alert("Default value is selected if no case was true.");

          break;

      }

            

    </script>