You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/jquery-basics/traversing.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -15,23 +15,23 @@ There are four methods for finding the parents from a selection: `$.fn.parent`,
15
15
<divclass="example"markdown="1">
16
16
Selecting an element's direct parent
17
17
18
-
$('#myList').parent();
18
+
$('#myList').parent();
19
19
</div>
20
20
<divclass="example"markdown="1">
21
21
Selecting all the parents of an element that match a given selector
22
22
23
-
$('#myList').parents('div.section');
23
+
$('#myList').parents('div.section');
24
24
</div>
25
25
<divclass="example"markdown="1">
26
26
Selecting all the parents of an element up to, but *not including* the selector
27
27
28
-
var section = $('div.section');
29
-
$('#myList').parentsUntil(section);
28
+
var section = $('div.section');
29
+
$('#myList').parentsUntil(section);
30
30
</div>
31
31
<divclass="example"markdown="1">
32
32
Selecting the closest parent, note that only one parent will be selected.
33
33
34
-
$('#myList').closest('#navigation');
34
+
$('#myList').closest('#navigation');
35
35
</div>
36
36
### Children
37
37
@@ -40,12 +40,12 @@ There are only 2 methods for finding child elements from a selection: `$.fn.chil
40
40
<divclass="example"markdown="1">
41
41
Selecting an element's direct children
42
42
43
-
$('#myList').children('li');
43
+
$('#myList').children('li');
44
44
</div>
45
45
<divclass="example"markdown="1">
46
46
Finding all the links within a selection that match the selector
47
47
48
-
$('#myList').find('a.external');
48
+
$('#myList').find('a.external');
49
49
</div>
50
50
51
51
### Sibilings
@@ -55,17 +55,17 @@ The rest of the traversal methods within jQuery all deal with finding sibiling s
55
55
<divclass="example"markdown="1">
56
56
Selecting an element's next sibiling that matches the given selector
57
57
58
-
$('#myList').next('div.section');
58
+
$('#myList').next('div.section');
59
59
</div>
60
60
<divclass="example"markdown="1">
61
61
Selecting an element's previous sibiling that matches the given selector
62
62
63
-
$('#myList').prev('div.section');
63
+
$('#myList').prev('div.section');
64
64
</div>
65
65
<divclass="example"markdown="1">
66
66
Selecting an element's sibilings in both directions that matches the given selector
67
67
68
-
$('#myList').sibilings('div.section');
68
+
$('#myList').sibilings('div.section');
69
69
</div>
70
70
71
71
You can see all these methods metioned and more at the docs [http://api.jquery.com/category/traversing/tree-traversal/](http://api.jquery.com/category/traversing/tree-traversal/"Traversal documentation on api.jquery.com")
0 commit comments