본문 바로가기
2019/JavaScript

JS if

by SOLYI 2019. 12. 5.

 

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
<script>
      window.onload=function(){
         //다큐멘트에, 가져온다 btn버튼을. 클릭했을때
        document.getElementById("btn").onclick=function(){
            let a=parseInt(document.getElementById("jumsu").value);
            let result;
                if(a>=90)
                    result='수';
                else if(a>=80)
                    result='우';
                else if(a>=70)
                    result='미';
                else if(a>=60)
                    result='양';
                else
                    result='가';
 
            console.log(result);
            //console에 결과 출력.
            
        }
      }
 
</script>
 
 
 
<body>
    <form name="frm">
       <label for="jumsu">점수</label>
       <input type="text" name="jumsu" id="jumsu">
       <br>
       <input type="button" id="btn" value="결과보기">
    </form>
</body>
cs

 

반응형

'2019 > JavaScript' 카테고리의 다른 글

JS for문  (0) 2019.12.05
JS switch  (0) 2019.12.05
JS Onclick  (0) 2019.12.05
JS 산술 연산자  (0) 2019.12.05
JS 변수와 타입  (0) 2019.12.05