cycling jQuery_Succinctly | Page 36

You can pass jQuery more than one selector expression You can provide the jQuery function's first parameter several expressions separated by a comma: $('expression, expression, expression'). In other words, you are not limited to selecting elements using only a single expression. For example, in the example below, I am passing the jQuery function three expressions separated by a comma. Sample: sample24.html
jQuery

is the

Each of these expressions selects DOM elements that are all added to the wrapper set. We can then operate on these elements using jQuery methods. Keep in mind that all the selected elements will be placed in the same wrapper set. An inefficient way to do this would be to call the jQuery function three times, once for each expression. Checking wrapper set .length to determine selection It is possible to determine if your expression has selected anything by checking if the wrapper set has a length. You can do so by using the array property length. If the length property does not return 0, then you know at least one element matches the expression you passed to the jQuery function. For example, in the code below we check the page for an element with an id of "notHere." Guess what? It is not there! Sample: sample25.html 36