I have a listbox:
<div>
<select id="SelectBox" multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</div>
This listbox is allowing for multiple selections. All I am trying to do is count the number of selected items.
Here is my jQuery:
$("#SelectBox").change(function(){
countSelectedItems();
});
function countSelectedItems(){
var count = $("#SelectBox:selected").length;
alert(count);
}
I have researched this solution from this post, but it is not working. I continue to keep being alerted with 0
.
Here is my JSFiddle.
Any help is appreciated.