focus selector
描述:选择当前获得焦点的元素。
增补版本:1.6jQuery( ":focus" )
As with other pseudo-class selectors (those that begin with a ":"), it is recommended to precede :focus
with a tag name or some other selector; otherwise, the universal selector ( "*" ) is implied. In other words, the bare $( ":focus" )
is equivalent to $( "*:focus" )
. If you are looking for the currently focused element, $( document.activeElement )
will retrieve it without having to search the whole DOM tree.
示例:
Adds the focused class to whatever element has focus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
|