我正在使用我的多选框,但我不知道如何获取所选项目?
<select class="multiselect" multiple="" name="parlementId">
@foreach (Politicus p in politici)
{
<option value="@p.politicusID">@Html.DisplayName(p.Account.voornaam.ToString())</option>
}
</select>
$('.multiselect').chosen({ width: '500px', allow_single_deselect: true, max_selected_options: 5 });
$('.multiselect').on('change', function (evt, params) {
//this is where I need to know which options are selected
});
答案 0 :(得分:1)
var values = $(".multiselect").chosen().val();
// this will give you values in an array
或:
var values = $(".multiselect").val();