<!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>단위 변환</h1>
<p>cm을 선택한 단위로 변환합니다</p>
<label for=""><input type="text" class="input"> cm</label>
<p>↓ ↓ ↓ ↓ ↓ 변환 ↓ ↓ ↓ ↓ ↓</p>
<div class="box" style="border: 1px solid black; width:170px; height:20px; float:left;"></div>
<select name="" id="" style="margin-left: 8px; clear:both;">
<option value="mm">mm</option>
<option value="inch">inch</option>
<option value="m">m</option>
</select>
<script>
let 입력 = document.querySelector("input")
let 결과 = document.querySelector(".box")
let 셀렉 = document.querySelector("select")
셀렉.addEventListener("change", () => {
if (셀렉.value == "mm") {
결과.textContent = 입력.value * 10
}
else if (셀렉.value == "inch") {
결과.textContent = 입력.value / 2.5
}
else if (셀렉.value == "m") {
결과.textContent = 입력.value / 100
}
})
</script>
</body>
</html>