JAVA_EE/JQuery
[21.10.06] exam07(02_jQueryEvent) - Key이벤트(keypress)
luvforjunk
2021. 10. 7. 02:44
728x90
반응형
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../css/event.css">
</head>
<body>
<h1>Key 이벤트 확인하기</h1>
<div id="input">
<input type="text">
</div>
<h2>결과</h2>
<div id="result"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
$(function(){
var count = 0;
// keypress는 대소문자는 구분하지만 그 외 특수키는 인식 못 함
$('#input > input[type=text]').keypress(function(){
count++;
$('#result').html('key count : ' + count);
});
});
</script>
</body>
</html>
728x90
반응형