Programming/JavaScript
oninput / onchange
dev?
2022. 5. 30. 12:33
반응형
oninput | onchange |
input, textarea 태그에서만 사용 가능 | input, textarea, select 태그에서만 사용 가능 |
입력 할 때마다 바로바로 데이터를 확인 | 태그에서 초점(focus)를 잃은 순간에 작동 = 데이터를 입력 하고 다른 곳을 클릭 하면 작동 |
1. oninput
- input / textarea 태그에서 데이터 입력 시에 주로 사용
- 입력할 때마다 바로 데이터 확인 가능
- javascript 이벤트 ( 리스너 )
- 유효성 검사에 주로 사용
See the Pen oninput by Dorad (@doradji) on CodePen.
2. onchange
- input, textarea, select 태그에서 데이터 입력시에 주로 사용
- 태그 밖의 영역 선택시 작동
See the Pen onchange by Dorad (@doradji) on CodePen.
https://coding-food-court.tistory.com/19
https://www.w3schools.com/jsref/event_oninput.asp
반응형