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

[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>


결과보기



분류 제목
attribute HTML - kind 속성 - 텍스트트랙 종류 지정 (= kind속성 = 카인드속성) ※ 트랙종류
attribute HTML - title 속성 ★ - 요소애 대한 추가 정보 지정 (= title속성 = 타이틀속성)
attribute HTML - enctype 속성 - 폼데이터 인코딩방식 지정 (= enctype속성 = 인크타입속성/잉크타입…
attribute HTML - onsubmit 속성 ★ - 폼데이터 제출 시 실행 (= onsubmit속성 = 온서브미트속성/…
attribute HTML - onseeked 속성 - (오디오/비디오) 재생위치 변경 종료 시, 실행할 코드 지정. (= o…
attribute HTML - ononline 속성 - 브라우저가 온라인으로 작동할 때 실행 (= ononline속성 = 온온…
form HTML - <input type="radio"> 태그 - 오직 1개의 요소만 선택 (= 인풋라디오타입/라디…
attribute HTML - ondragleave 속성 - 드래그 한 요소가 드롭박스 이탈 시 실행 (= ondragleav…
attribute HTML - onemptied 속성 - 미디어 소스가 비어있거나 삭제된 경우에 실행 (= onemptied속…
attribute HTML - src 속성 ★ - 외부 리소스 URL주소 지정 (= src속성 = 에스알시속성/에스알씨속성/소…
attribute HTML - cellspacing 속성 - 테이블셀간의 간격 지정 (= cellspacing속성 = 셀스페이…
attribute HTML - onabort 속성 - 미디어 파일 로드 중단 이벤트 발생 시 실행할 코드 정의 (= onabo…
attribute HTML - srclang 속성 - 트랙태그 소스의 언어코드 지정 (= srclang속성 = 에스알시랭속성/…
attribute HTML - onpageshow 속성 - 사용자가 웹페이지 탐색 시 실행 (= onpageshow속성 = 온…
attribute HTML - form 속성 - 해당 요소가 속하는 폼요소 지정 (= form속성 = 폼속성) ※ 폼 밖에 위…
form HTML - <input type="hidden"> 태그 - 숨겨진 입력 필드 지정 (= 사용자 몰래 입력값…
attribute HTML - label 속성 - 요소에 대한 꼬리표 지정 (= label속성 = 레이블속성/라벨속성)
attribute HTML - headers 속성 - 관련된 헤더셀ID 목록 지정 (= headers속성 = 헤더스속성/헤더즈…
attribute HTML - onstalled 속성 - (오디오/비디오) 이용불가 (=사용불가) 시 실행 (= onstall…
form HTML - <input type="number"> 태그 - 숫자 입력 (= 인풋넘버타이/넘버타입인풋/넘버인…
2/18
목록
찾아주셔서 감사합니다. Since 2012