Python/Muzi
JS강화학습02. 버튼 클릭시 input text 값 가져와서 연산하고 출력하기
미눅스[멘토]
2023. 7. 12. 09:19
728x90
ex02.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script>
function myclick(){
var obj = document.querySelector('.it').value;
num = parseInt(obj);
num2 = num * 2;
console.log(num2)
document.querySelector('.it').value = num2;
}
</script>
</head>
<body>
EX02
<input class="it" type="text" value="100" />
<input type="button" value="DOUBLE" onclick=" myclick()">
</body>
</html>