Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
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
Tags more
Archives
Today
Total
관리 메뉴

기록

자바스크립트 더하기 버튼 (파이선9) 본문

JAVASCRIPT&JQUERY

자바스크립트 더하기 버튼 (파이선9)

9400 2023. 1. 10. 15:58
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
input{
	width : 30px;
}
</style>
<script type="text/javascript">

function myclick(){
	let it1 = document.querySelector('#it1').value;
	let it2 = document.querySelector('#it2').value;
	let it3 = document.querySelector('#it3');
	
	let num1 = parseInt(it1);
	let num2 = parseInt(it2);
	
	let result = num1 + num2;
	
	it3.value=result;
}

</script>
</head>
<body>
<input type="text" id="it1" />
+
<input type="text" id="it2" />
<input type="button" value="=" onclick="myclick()" />
<input type="text" id="it3" />


</body>
</html>

출력성공

Comments