As in topic - how to get selected items count in ListBox with jQuery, while user is selecting new item?
I have these code:
@Html.ListBoxFor(x => Mode
Adding my comment as answer....
If it is a multi-select, you will want to use....
$('#StatesID').on('change', function(){
countStates();
});
otherwise click does not fire if the user selects more that one option at a time.
Try this :
$(document).ready(function() {
$('#StatesID').click(countStates);
});