这是代码
@Html.ListBoxFor(model => model.headerList, new MultiSelectList(Model.headerList), new { id = "AvailableGenres", size = "50", value=1,style = "height: 300px;" })</div>
<input id="btnAddAll" type="button" value=" >> " onclick="addallItems();" />
<input id="btnAdd" type="button" value=" > " onclick="addItem();" />
<input id="btnRemove" type="button" value=" < " onclick="removeItem();" />
<input id="btnRemoveAll"type="button" value=" << " onclick="removeallItems();" />
<div style="height:-1px;float:right;">
@Html.ListBoxFor(model => model.ChosenGenres, new MultiSelectList(Model.ChosenGenres), new { id = "ChosenGenres", @class = "ChosenGenreslist", size = "50", style = "height: 300px;" })
</div>
答案 0 :(得分:0)
按选项的文字
按字母顺序对第二个列表进行排序var options = $('#ChosenGenres option');
options.sort(function (x, y) {
return x.text > y.text;
});
$('#ChosenGenres').empty().append(options);
附注:建议您学习使用Unobtrusive JavaScript