javascript中的onblur事件 [英] onblur event in javascript

查看:132
本文介绍了javascript中的onblur事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想准确理解javascript中的onblur事件是什么。



在我的项目中,大多数地方以这种方式使用



txtEmployeeID.Attributes.Add(onblur,fnGetEmployeeName(););





我试着去谷歌。但我得到的答案就像是onblur属性激发了元素失去焦点的那一刻。





我无法理解这个。请帮忙。

I want to understand exactly what is onblur event in javascript.

In my project most of the places its used in this way

txtEmployeeID.Attributes.Add("onblur", "fnGetEmployeeName();");


I tried to google . But the answer i m getting is like "The onblur attribute fires the moment that the element loses focus."


I am unable to understand this. kindly help.

推荐答案

当当前控件不再有光标内部时,会激活onblur事件。因此,如果您在文本框中键入内容并单击其他内容,则会触发onblur事件,因为光标不再聚焦于该控件上



看到这个 [ ^ ]
The "onblur" event fires when the current control no longer has the cursor inside of it. So if you type something in the textbox and click something else, the "onblur" event fires because the cursor is not focused on that control anymore

See this[^]


在Windows窗体应用程序中,等效事件将类似于OnLostFocus。事件在离开txtEmployeeID之前和下一个控件之前触发将获得焦点。如果有人输入了无效值,您可以使用它为编辑框着色为红色。



希望这更加清晰。



祝你好运!
In a windows forms application the equivalent event would be something like OnLostFocus. The event fires between leaving txtEmployeeID and just before the next control will get the focus. You could use it to color the edit box red in case someone entered an invalid value for example.

Hopefully that makes it somewhat more clear.

Good luck!

javascript中的onblur事件将在用户在单击内部后单击控件侧时执行。这里是将onblur事件应用于名为txtEmployeeID的文本框,并指定在onblur事件发生时执行的特定方法以及此事件只有在单击鼠标指针后才能在文本框txtEmployeeID外部单击时执行。请记住,它在离开文本框后只会执行一次。如果必须再次执行它,则必须单击文本框旁边。
The onblur event in javascript will execute when the user click out side the control after clicking inside.Here you are applying the onblur event to the textbox named txtEmployeeID and assigning the particular method for executing when the onblur event occurs and this event will execute when you click outside the textbox txtEmployeeID only after clicking the mouse pointer in to it. And remember that it will execute only once after leaving the the textbox. If you have to execute it again you have to click in side the textbox.


这篇关于javascript中的onblur事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆