How to get number of selected options using jquery?

后端 未结 4 475
谎友^
谎友^ 2020-12-13 12:19

I have a multiple selection list which have more than 5 options. But i want to restrict the selection of the options to 2 or 3 options. How to do it using jquery? How to get

4条回答
  •  猫巷女王i
    2020-12-13 12:58

    You can get the number of selected items in the multiselect with the following:

    $('#selectList :selected').length
    

    Where #selectList is the id of your .

提交回复
热议问题