如何根据选定的值对jquery multiselect进行排序???我想首先在jquery multiselect中显示所选选项,然后是所有未选择的vales。
like below multiselect having two values selected
<select id="the-select">
<option value="1">First option</option> \\selected
<option value="2">Second option</option>
<option value="3">Third option</option>\\selected
</select>
but i need to show the multiselect as its showing below
<select id="the-select">
<option value="1">First option</option> \\selected
<option value="3">Third option</option>\\selected
<option value="2">Second option</option>
</select>
Thanks
答案 0 :(得分:1)
这是3行的解决方案:
var selected = $("select[name=yourselectname] option:selected"); //get every selected option
selected.remove(); //remove them from the select
$("select[name=yourselectname]").prepend(selected); //add them at the beginning of the select
经过测试和推荐: - )