본문 바로가기
Python/Muzi

Jquery강화학습02. text값 가져와서 연산하기

by 미눅스[멘토] 2023. 7. 12.
728x90
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(function(){
	$('#btn').bind('click', function(){
		myclick()
	});
});


function myclick(){
	var obj = $('.it').val();
	var num = parseInt(obj);
	$('.it').val(num * 2) ;
	
}


</script>

</head>
<body>
EX02
<input class="it" type="text" value="100" />
<input type="button" value="DOUBLE" id="btn">

</body>
</html>

 

 

 

DOUBLE버튼 클릭시

 

 

 

 

결과