JavaScript event focus

Focus event occurs when an element (such as links or form) gain or lose focus.

Example:

. 1 <! DOCTYPE HTML>
 2 <HTML lang = " EN " >
 . 3 <head>
 . 4      <Meta charset = " UTF-. 8 " >
 . 5      <title> Focus Events </ title>
 . 6 </ head>
 . 7 <body>
 . 8 <h1> lost focus after transfer capital </ h1>
 9 <the p-> input character can be converted to uppercase! </ the p->
 10 <the INPUT the above mentioned id = " S " >
 11 <br> <br>
 12 <the Button> Click me, input loses focus </ the Button>
 13 <the p-the above mentioned id = "         var the EL = document.getElementById ( ' S ' );
 16          EL.addEventListener ( ' Blur ' , CheckKey, to false );
 . 17  
18 is          function CheckKey (E) {
 . 19              var STR = EL.value;
 20 is              Alert ( " character you typed They are: " + STR);
 21 is              OUT .textContent = str.toUpperCase ();
 22 is          }
 23 is      </ Script>
 24 </ body>
 25 </ HTML>

 

Guess you like

Origin www.cnblogs.com/q2546/p/11290894.html