• 회원가입
  • 로그인
  • 구글아이디로 로그인

[attribute] HTML - oninput 속성 ★ - 사용자 입력값 변경 시 바로 실행 (= oninput속성 = 온인풋속성) ※ 온인풋이벤트

목차
  1. oninput 예제 - 사용자 입력값 변경 시 이벤트 발생
  2. oninput 정의
  3. oninput 구문
  4. oninput 예제 - 계산 결과를 <output> 태그에 넣기

 

oninput 예제 - 사용자 입력값 변경 시 이벤트 발생

 

<input type="text" id="hz" oninput="homzzang()">


<p id="demo"></p>


<script>

function homzzang() {

  var x = document.getElementById("hz").value;

  document.getElementById("demo").innerHTML = "입력값: " + x;

}

</script>

 

결과보기

 

oninput 정의

 

사용자 입력값 받으면 oninput 속성 실행.

 


 

1. oninput 속성 사용 가능 태그 종류

<input> (<input type="password">, <input type="search">, <input type="text">), <textarea>


2. oninpu vs. onchange 이벤트. 

  • oninput 이벤트 - ① 요소값 변경 직후 발생. ② <input>, <textarea> 요소에서만 작동.
  • onchange 이벤트 - ① 요소값 변경 후 요소가 포커스 잃을 때 발생. ② 모든 요소에서 작동

 

3.

IE9 이상 주요 최신 브라우저 모두 지원.

 

 

oninput 구문

 

<element oninput="script">

 


[속성값]

 

script

oninput 이벤트 발생 시 실행할 JS코드

 

 

oninput 예제 - 계산 결과를 <output> 태그에 넣기

 

<form action="/action_page.php" id="hz" oninput="x.value=parseInt(a.value)+parseInt(b.value)">

<input type="range" id="a" name="a" value="50">

+ <input type="number" id="b" name="b" value="100">

<br><br>

<input type="submit">

</form>


<output form="hz" id="x" name="x" for="a b"></output>


결과보기



분류 제목
form HTML - <input type="text"> 태그 - 1줄 텍스트 입력 (= 인풋텍스트타입/텍스트타입인풋…
attribute HTML - charset 속성 - 문자셋 지정 (= charset속성 = 차셋속성) ※ 문자인코딩, 언어셋
form HTML - <input type="url"> 태그 - http(s) 프로토콜 형식의 URL 주소 입력 (=…
attribute HTML - onmousewheel 속성 - (폐기예고) 마우스휠 움직일 때 실행 (= onmousewhe…
attribute HTML - onafterprint 속성 - 인쇄 대화상자 닫힌 이후 이벤트 발생 시 실행할 코드 정의 (=…
attribute HTML - oninput 속성 ★ - 사용자 입력값 변경 시 바로 실행 (= oninput속성 = 온인풋속…
attribute HTML - shape 속성 - 이미지맵 링크영역 모양 지정 (= shape속성 = 쉐이프속성) ※ 에어리어…
form HTML - <input type="search"> 태그 - 검색어 입력 (= 인풋서치타입/서치타입인풋/서치…
attribute HTML - sizes 속성 - 해상도별 이미지나 아이콘, 미디어(오디오/비디오) 등의 크기 지정 (= si…
form HTML - <input type="submit"> 태그 - 서버로 데이터 제출/전송 (= 인풋타입서브미트/…
attribute HTML - onload 속성 ★ - 지정 객체가 로드된 경우 실행 (= onload속성 = 온로드속성) ※…
attribute HTML - span 속성 ★ - 테이블 (열/열그룹) 병합 개수 지정 (= span속성 = 스팬속성) ※ …
form HTML - <input type="file"> 태그 - 업로드 할 파일 선택 (= 파일첨부/첨부파일 입력필…
attribute HTML - cite 속성 - (인용출처/삭제이유/삽입이유) 주소 연결 (= cite속성 = 사이트속성)
attribute HTML - dir 속성 - 텍스트 출력방향 지정 (= dir속성 = 디르속성|디렉션속성)
form HTML - <input type="reset"> 태그 - 입력창 초기화/재설정 (= 입력한 폼데이터 비우기…
attribute HTML - async 속성 ★★★ - 비동기적으로 외부스크립트 실행 지정 (= async속성 = 에이싱크속…
attribute HTML - onended 속성 - 미디어 재생 끝날 때 실행 (= onended속성 = 온엔디드속성) ※ …
attribute HTML - novalidate 속성 - 폼데이터 제출 시, 유효성 평가 생략 (= novalidate속성 …
attribute HTML - translate 속성 - 요소 내용 번역 허용 여부 지정 (= translate속성 = 트랜슬…
7/18
목록
찾아주셔서 감사합니다. Since 2012