大家好,这是我的代码:
<select id='first'>
<option value='1'> First </option>
<option value='2'> Second </option>
<option value='3'> Three </option>
</select>
这是我的select2代码:
$("#first").select2();
下面是获取选定值的代码。
$("#first").select2('val'); // It returns first,second,three.
这将返回一个文本,例如first,second,three
,我想要得到1,2,3
。
这意味着我需要选择框的值,而不是文本。