<select id="selectid"
xm-select-skin="default" xm-select="jiebr" xm-select-type="2">
</select>
formSelects.on('jiebr', function (id, vals, val, isAdd, isDisabled) {
var $options = $("#selectid").find("option");
var newarr = new Array();
var oldvals = vals;
var addvar;
var delvar;
if (isAdd) {
oldvals.push(val);
} else {
delvar = val.value;
}
if (vals.length > 0) {
var valstr = JSON.stringify(oldvals);
//重新排序
$options.each(function (index, element) {
var ovle = "\"" + $(element).val() + "\"";
if (valstr.indexOf(ovle) > -1 && $(element).val() != delvar) {
//返回新的数组
newarr.push($(element).val());
}
});
}
formSelects.value('selectid', newarr);
return false;
});
formSelects.render();
layui formSelects 多选后按下拉顺序排序
最新推荐文章于 2024-03-15 11:32:30 发布