03/31 11차 자바스크립트 과제

Noh Sinyoung·2023년 3월 31일
0

과제

목록 보기
11/27
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>BMI 테스트</h1>
    <label for=""><input type="text" name="" id="height"></label>
    <br><br>
    <label for="">체중 <input type="text" name="" id="weight"></label>
    <br><br>
    <button>계산</button>
    <hr>

    <h1>BMI 수치 : <span id="bmi"></span></h1>
    
    <script>
        const= document.querySelector("#height")
        const 체중 = document.querySelector("#weight")

        let 입력한키
        let 입력한체중
        let bmi

        const bmi지정 = document.querySelector("#bmi")
        
        const 버튼 = document.querySelector("button")
        버튼.addEventListener("click", function() {
            입력한키 =.value / 100
            입력한체중 = 체중.value
            bmi = 입력한체중 / (입력한키*입력한키)
            
            bmi지정.innerHTML = bmi.toFixed(3)
        })
        
    </script>




</body>
</html>

0개의 댓글