0
我有一个Select2的问题,当我用鼠标单击十字标志时(请注意allowClear为真)select2:unselect
事件被触发,但选定的值之前的值仍然选择一段时间。select2:取消选择不能正常工作
<select id='select2'>
<option value='1'>option 1</option>
</select>
$("#select2").select2({
placeholder: "placeholder",
dropdownAutoWidth: true,
allowClear: true
})
$("#select2").on("select2:select select2:unselect", function (e) {
var currentValue = $(this).val();
console.log($(this).val());
setTimeout(function() {
console.log($("#select2").val());
}, 2000)
});
我需要得到当前值,如果没有选择我会期望为空。
有没有正确的方法来获取当前的select2值?
这里是演示 - jsfiddle