Computer >> 컴퓨터 >  >> 프로그램 작성 >> JavaScript

JavaScript에서 oninput 이벤트의 사용법은 무엇입니까?


입력 상자에 값이 추가되면 oninput 이벤트가 발생합니다. 다음 코드를 실행하여 oninput 구현 방법을 배울 수 있습니다. 자바스크립트의 이벤트 -

예시

<!DOCTYPE html>
<html>
   <body>
      <p>Write below:</p>
      <input type = "text" id = "newInput" oninput = "inputFunc()">
      <p id = "demo"></p>
      <script>
         function inputFunc() {
            var a = document.getElementById("newInput").value;
            document.write("Typed: " + a);
         }
      </script>
   </body>
</html>