← Go back to homepage
Counting the Number of Options in a  Dropdown with jQuery

Counting the Number of Options in a Dropdown with jQuery

Let’s say you have this (very) simple dropdown:

United States United Kingdom

And one day you decide to figure out how much elements or “option” tags the given “select” has.

It’s easy:

var items = $('#my_dropdown option').length; alert(items);

The above should immediately display “2” since we have 2 countries in the select dropdown.

← Go back to homepage