How to count the number of options in a select box using JQuery

Written by Ian Carnaghan · 10 sec read >

This can be done using the jQuery length property

You will use the following command to determine if there are any options within the select box.

var length = $('#selectBoxId > option').length;

#selectBoxId should be replaced with the ID of your select box.

Last Updated On March 21, 2018
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. Profile

Leave a Reply

Notify of