JQuery
[JQuery] input text 엔터키 이벤트
chsr
2021. 7. 19. 11:24
728x90
반응형
■ JQuery input text 엔터키 이벤트
■ 사용법
<input type="text"> 폼에서 키보드 엔터키 입력 시 이벤트 발생시키는 방법
<input type="text" id="searchKwd">
<input type="text" id="searchKwd2">
<input type="text" id="searchKwd3">
- 단일 input 엔터키 이벤트
<script type="text/javascript">
$("#searchKwd").keydown(function(key) {
if( key.keyCode == 13 ){
console.log('Enter');
}
});
</script>
- 다중 input 엔터키 이벤트 *콤마로 구분
<script type="text/javascript">
$("#searchKwd, #searchKwd2, #searchKwd3").keydown(function(key) {
if( key.keyCode == 13 ){
console.log('Enter');
}
});
</script>
728x90
반응형