Jquery method of obtaining focus: Determine whether the object obtains focus by judging whether [$(object).is(":focus")] is equal to true, where the [:focus] selector is used to select the object that obtains focus. Element, the [is()] method is used to check whether the selected element matches the selector.
The operating environment of this tutorial: Windows 7 system, jquery version 1.10.2. This method is suitable for all brands of computers.
How jquery gets focus:
In jquery, you can judge whether $(object).is(":focus")
is equal to true to determine whether the object has focus.
When the object has focus, $(object).is(":focus")
will return true, otherwise it will return false.
Example:
var isFocus=$("#tRow").is(":focus"); if(true==isFocus){ alert("focus"); }else{ alert("blur"); }
Description:
is()
method is used to check whether the selected element matches the selector.
:focus
The selector is used to select the element that receives focus.
Tip: Elements that receive keyboard events or other user input allow the :focus
selector.
Related free learning recommendations: javascript (video)
The above is the detailed content of Whether jquery gets focus. For more information, please follow other related articles on the PHP Chinese website!