GlobalEventHandlers.onchange

You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!

onchange 속성은 change 이벤트의 이벤트 핸들러를 설정하고 반환합니다.

구문

target.onchange = functionRef;

functionRefnull 또는 이벤트 핸들러를 지정하는 JavaScript function 함수 중 하나여야 합니다.

예제

HTML

<input type="text" placeholder="Type something here, then click outside of the field." size="50">
<p id="log"></p>

JavaScript

let input = document.querySelector('input');
let log = document.getElementById('log');

input.onchange = handleChange;

function handleChange(e) {
  log.textContent = `The field's value is
      ${e.target.value.length} character(s) long.`;
}

결과

명세

명세 상태 비고
HTML Living Standard
The definition of 'onchange' in that specification.
Living Standard  

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onchangeChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support

같이 보기