Nick Heiner Nick Heiner - 1 year ago 74
jQuery Question

jQuery: See how many elements a selector matched?

If I have a selector like


How can I see how many items that matched?

Alternatively, is there an easy way to see if more than zero elements were matched?

Answer Source

call .length on the returned set.

Do not use .size because:

The .size() method is deprecated as of jQuery 1.8