Q:

Get number of visible select options

I have a select that looks like this:
<select id="days">
<option value="nothing">Select day</option>
<option value="monday2">Monday</option>
<option value="tuesday2">Tuesday</option>
<option value="wednesday2">Wednesday</option>
<option value="thursday2">Thursday</option>
<option value="friday2">Friday</option>
<option value="saturday2">Saturday</option>
<option value="sunday2">Sunday</option>
</select>

I want to know how many of the options in the select days are visible. The reason to this is because I have a function that may hide some of these options
I've tried something like this but it didnt work:
visibleoptions = $("days option:visible").index()+1;

Thanks in advance

A:

Your id selector is malformed, it should be prefixed with a hash sign. With a fixed selector, you only have to use the length property:
var visibleCount = $("#days option:visible").length;

