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

[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 - onsuspend 속성 - (오디오/비디오)를 브라우저가 일시중지 시킬 때 실행 (= onsus…
attribute HTML - lang 속성 - 요소 내용 언어코드 지정 (= lang속성 = 랭속성)
attribute HTML - required 속성 ★ - 폼데이터 제출 전 (입력필수/선택필수) 지정 (= required속…
etc HTML - 스크린리더기가 읽는 HTML요소 정보값 종류 (= Screen Reader provides th…
attribute HTML - onprogress 속성 - (오디오/비디오) 다운로드 시 실행 (= onprogress속성 =…
attribute HTML - onmouseout 속성 ★ - 마우스커서가 지정요소 밖으로 이동 시 실행 (= onmouseo…
attribute HTML - onselect 속성 - 요소 내용 선택 시 실행 (= onselect속성 = 온실렉트속성) ※…
attribute HTML - defer 속성 ★★★ - 페이지 파싱 완료 후 외부스크립트 실행 (= defer속성 = 디퍼속…
attribute HTML - onmouseup 속성 - 마우스버튼 올라갈 때 실행 (= onmouseup속성 = 온마우스업속…
attribute HTML - list 속성 - 인풋에 입력 가능한 데이터리스트 지정 (= list속성 = 리스트속성) ※ 입…
attribute HTML - on으로 시작하는 속성에서 2개 이상의 여러 JS함수 실행 방법
attribute HTML - tabindex 속성 - 탭색인번호 지정 (= tabindex속성 = 탭인덱스속성) ※ 탭넵비게…
attribute HTML - ondrag 속성 - 드래그 이벤트 시 실행할 코드 지정 (= ondrag속성 = 온드래그속성)…
attribute HTML - onreset 속성 - 폼 초기화 시 실행 (= onreset속성 = 온리셋속성) ※ onres…
attribute HTML - onvolumechange 속성 - (오디오/비디오) 볼륨변경 시 실행 (= onvolumech…
attribute HTML - data-* 속성 ★★★ - 특정 (페이지/애플리케이션)의 사용자 데이터 저장 (= data-속…
attribute HTML - oncopy 속성 - 요소의 텍스트나 이미지 태그를 복사 시 실행 (=oncopy속성 = 온카피…
attribute HTML - ondurationchange 속성 - 재생시간 데이터가 변경될 때 실행 (= onduratio…
form HTML - <input type="datetime-local"> 태그 - 년월일시분 입력 (= 인풋데이트타…
attribute HTML - content 속성 ★ - 메타데이터 값 지정 (= content속성 = 콘텐트속성|컨텐트속성)
4/18
목록
찾아주셔서 감사합니다. Since 2012