條件判斷 if...else if...else- if(number < 5){
- document.getElementById("小於5");
- document.getElementById('input').reset();
- }
- else if(number < 10){
- document.getElementById("小於10");
- document.getElementById('input').reset();
- }
- else{
- document.getElementById("大於10");
- document.getElementById('input').reset();
- }
複製代碼 條件判斷 switch- switch(number){
- case 1:
- document.getElementById("You want Coffee?");
- break;
- case 2:
- document.getElementById("Tea?");
- break;
- case 3:
- document.getElementById("Table!");
- break;
- default:
- document.getElementById("nullptr");
- break;
- }
複製代碼 |