티스토리 뷰

💼 정보 ver1.0

event.which

James Wetzel 2012. 9. 13. 19:53
728x90
반응형

키 또는 마우스 이벤트의 경우이 속성은 눌러 된 특정 키 또는 버튼을 나타냅니다.

Description: For key or mouse events, this property indicates the specific key or button that was pressed.


<!DOCTYPE html>
<html>
<head>
 
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
 
<input id="whichkey" value="type something">
<div id="log"></div>
<script>$('#whichkey').bind('keydown',function(e){
  $
('#log').html(e.type + ': ' +  e.which );
});  </script>

</body>
</html>


<!DOCTYPE html>
<html>
<head>
 
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
 
<input id="whichkey" value="type something">
<div id="log"></div>
<script>
$
('#whichkey').bind('mousedown',function(e){
  $
('#log').html(e.type + ': ' +  e.which );
});
</script>

</body>
</html>


상세 설명: http://api.jquery.com/event.which/



728x90
반응형