I am setting the focus on a certain input field when loading a page using the following line:
当我使用以下行加载页面时,我将焦点放在某个输入字段上:
$('#myInputID').focus();
Is there a way that I can undo or remove this focus when hovering over a certain element ? (The focus does not have to be reset after leaving this element.)
是否有一种方法可以在鼠标悬停在某个元素上时取消或删除这个焦点?(离开该元素后,焦点不需要重置。)
I couldn't find a function that is the opposite to the above in jQuery or would otherwise work here.
在jQuery中,我找不到一个与上面的函数相反的函数。
Can someone help me with this?
有人能帮我一下吗?
3 个解决方案
#1
155
Use .blur().
使用.blur()。
The blur event is sent to an element when it loses focus. Originally, this event was only applicable to form elements, such as
<input>
. In recent browsers, the domain of the event has been extended to include all element types. An element can lose focus via keyboard commands, such as the Tab key, or by mouse clicks elsewhere on the page.当模糊事件失去焦点时,它被发送到一个元素。最初,这个事件只适用于表单元素,如。在最近的浏览器中,事件的域被扩展为包含所有元素类型。元素可以通过键盘命令(如选项卡键)或鼠标单击页面其他地方而失去焦点。
$("#myInputID").blur();
#2
9
check up blur()
:
检查模糊():
$('#textarea').blur()
source: http://api.jquery.com/blur/
来源:http://api.jquery.com/blur/
#3
0
For all textbox :
所有文本框:
$(':text').blur()
#1
155
Use .blur().
使用.blur()。
The blur event is sent to an element when it loses focus. Originally, this event was only applicable to form elements, such as
<input>
. In recent browsers, the domain of the event has been extended to include all element types. An element can lose focus via keyboard commands, such as the Tab key, or by mouse clicks elsewhere on the page.当模糊事件失去焦点时,它被发送到一个元素。最初,这个事件只适用于表单元素,如。在最近的浏览器中,事件的域被扩展为包含所有元素类型。元素可以通过键盘命令(如选项卡键)或鼠标单击页面其他地方而失去焦点。
$("#myInputID").blur();
#2
9
check up blur()
:
检查模糊():
$('#textarea').blur()
source: http://api.jquery.com/blur/
来源:http://api.jquery.com/blur/
#3
0
For all textbox :
所有文本框:
$(':text').blur()