Counting the Number of Options in a  Dropdown with jQuery

Counting the Number of Options in a Dropdown with jQuery

Dzhuneyt Ahmed - Author of this post

By: Dzhuneyt Ahmed

Posted · 1 min read

Outdated: This post uses jQuery, which is no longer necessary for DOM operations. The same result can be achieved with vanilla JavaScript: document.querySelectorAll(‘#my_dropdown option’).length.

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.

Dzhuneyt Ahmed

Dzhuneyt

Helping teams build reliable cloud infrastructure — without the bloated bill.

Social

My Other Blogs

© 2026 Dzhuneyt Ahmed. All rights reserved.