HTML&CSS&Javscript&Jquery
190823 첫번째 문제
猫猫
2019. 8. 23. 17:02
반응형
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
var get =0;
var post=0;
$(document).ready(function(){
$("#get").click(function(){
get = parseInt($("#get").val());
console.log(get);
});
$("#post").click(function(){
post = parseInt($("#post").val());
console.log(post);
});
var $radio = $("#radio");
$radio.click(function(){
if($radio.is(":checked")){
var sum = get+post;
console.log(sum);
}
});
});
</script>
</head>
<body>
<div>
GET: <input type="text" id="get">
<input type="button" id="chk1" value="확인"><br>
</div>
<div>
POST: <input type="text" id="post">
<input type="button" id="chk2" value="확인"><br>
</div>
<fieldset>
<legend>제목</legend>
<input type="radio" width="150" id="radio" value="click">Click me!
</fieldset>
</body>
</html>
뭔가 희한했던 문제
text박스 클릭할때마다 console.log로 text박스 값 출력하고
radio 버튼 체크 되면 두 text의 값을 더해서 console.log에 띄운다
반응형