JavaScript gets focus and lose focus

onBlur: When the input box loses focus;

onFocus: After obtaining the focus input box;

 

1, directly in the attribute of the element;

<input type="text"  id="test"  οnblur=" test() " >

 

2, binding events with js

<Script> 
var Test1 = document.getElementById ( 'Test'); 
Test1 .onblur = function () {// function executed}; 
</ Script>

  

 

Guess you like

Origin www.cnblogs.com/guorongtao/p/12395578.html