Skip to content

Commit 493807e

Browse files
committed
Add example for comma-separated list of selectors. Fixes jquerygh-702. Closes jquerygh-706.
1 parent 82c7503 commit 493807e

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

page/using-jquery-core/selecting-elements.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $( ".myClass" );
2020
## Selecting Elements by Attribute
2121

2222
```
23-
$( "input[name='first_name']" ); // Beware, this can be very slow in older browsers
23+
$( "input[name='first_name']" );
2424
```
2525

2626
## Selecting Elements by Compound CSS Selector
@@ -29,6 +29,12 @@ $( "input[name='first_name']" ); // Beware, this can be very slow in older brows
2929
$( "#contents ul.people li" );
3030
```
3131

32+
## Selecting Elements with a Comma-separated List of Selectors
33+
34+
```
35+
$( "div.myClass, ul.people" );
36+
```
37+
3238
## Pseudo-Selectors
3339

3440
```
@@ -54,16 +60,8 @@ Elements that have not been added to the DOM will always be considered hidden, e
5460

5561
## Choosing Selectors
5662

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.
6564

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.
6765

6866
### Does My Selection Contain Any Elements?
6967

0 commit comments

Comments
 (0)