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

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

<시간/>

요소가 포커스를 받으면 onfocus 이벤트가 트리거됩니다. 다음 코드를 실행하여 onfocus 구현 방법을 배울 수 있습니다. 자바스크립트의 이벤트

예시

<!DOCTYPE html>
<html>
   <body>
      <p>Write below:</p>
      <input type = "text" onfocus = "newFunc(this)">
      <script>
         function newFunc(x) {
            x.style.background = "blue";
         }
      </script>
   </body>
</html>