JS--焦点

来源:互联网 发布:潍坊行知学校招生简章 编辑:程序博客网 时间:2024/05/22 06:10
1.获取焦点: $("#id").focus();
 

2.失去焦点:$("#id").blur(); 
 

注:在获取焦点时,如果失败了,可以延时50ms
eg:setTimeout(function (){$("#id").focus();},50); 

3.焦点事件:

onBlur:当失去输入焦点后产生该事件

onFocus:当输入获得焦点后,产生该事件

Onchange:当文字值改变时,产生该事件

eg:
<input onFocus="function(){}"></input>
0 0