入力された点数の判別
JavaScriptの基本
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <!doctype html> <html> <head> <meta charset="UTF-8"> <title>入力された点数の判別</title> </head> <body> <h1>入力された点数の判別</h1> <p>   <button onClick="btn()">判別する</button> </p> <h2 id="result">ここに結果を表示</h2> <script> 		function btn(){ 		var score = prompt('点数を半角数字で入力してください'); 			score = parseInt(score); 			 var element = document.getElementById('result'); 	  if (score === 100 ) {       	element.textContent = '100点満点おめでとう'; 	  }else 		if (score >= 80 ) { 		element.textContent = '80点以上よくできました'; 		}else 		if ( score >= 60 ) { 		element.textContent = '60点以上 合格です'; 		}else{	 		element.textContent = '60点未満 もっとがんばりましょう';   } } </script> </body> </html> | 
 
  
  
  
  
