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: page/using-jquery-core/selecting-elements.md
+8-10Lines changed: 8 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ $( ".myClass" );
20
20
## Selecting Elements by Attribute
21
21
22
22
```
23
-
$( "input[name='first_name']" ); // Beware, this can be very slow in older browsers
23
+
$( "input[name='first_name']" );
24
24
```
25
25
26
26
## Selecting Elements by Compound CSS Selector
@@ -29,6 +29,12 @@ $( "input[name='first_name']" ); // Beware, this can be very slow in older brows
29
29
$( "#contents ul.people li" );
30
30
```
31
31
32
+
## Selecting Elements with a Comma-separated List of Selectors
33
+
34
+
```
35
+
$( "div.myClass, ul.people" );
36
+
```
37
+
32
38
## Pseudo-Selectors
33
39
34
40
```
@@ -54,16 +60,8 @@ Elements that have not been added to the DOM will always be considered hidden, e
54
60
55
61
## Choosing Selectors
56
62
57
-
Choosing good selectors is one way to improve JavaScript's performance. A little specificity – for example, including an element type when selecting elements by class name – can go a long way. On the other hand, too much specificity can be a bad thing. A selector such as `#myTable thead tr th.special` is overkill if a selector such as `#myTable th.special` will get the job done.
58
-
59
-
jQuery offers many attribute-based selectors, allowing selections based on the content of arbitrary attributes using simplified regular expressions.
60
-
61
-
```
62
-
// Find all <a> elements whose rel attribute ends with "thinger".
63
-
$( "a[rel$='thinger']" );
64
-
```
63
+
Choosing good selectors is one way to improve JavaScript's performance. Too much specificity can be a bad thing. A selector such as `#myTable thead tr th.special` is overkill if a selector such as `#myTable th.special` will get the job done.
65
64
66
-
While these can be useful in a pinch, they can also be extremely slow in older browsers. Wherever possible, make selections using IDs, class names, and tag names.
0 commit comments