.prev( [selector ] )Returns: jQuery
Description: Get the immediately preceding sibling of each element in the set of matched elements. If a selector is provided, it retrieves the previous sibling only if it matches that selector.
-
version added: 1.0.prev( [selector ] )
-
selectorType: SelectorA string containing a selector expression to match elements against.
-
.prev()
method searches for the predecessor of each of these elements in the DOM tree and constructs a new jQuery object from the matching elements.
$()
function. If the selector is supplied, the preceding element will be filtered by testing whether it match the selector.
1
2
3
4
5
6
7
|
|
1
|
|
Examples:
Example 1
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
37
38
39
40
41
42
43
44
45
46
47
48
|
|
Demo:
Example 2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
|