Getting selected items count ListBox with jQuery

后端 未结 2 843
花落未央
花落未央 2021-01-24 01:24

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         


        
相关标签:
2条回答
  • 2021-01-24 01:29

    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.

    0 讨论(0)
  • 2021-01-24 01:36

    Try this :

    $(document).ready(function() {
        $('#StatesID').click(countStates);
    });
    
    0 讨论(0)
提交回复
热议问题