こんにちは、これは私のコードです:
<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
。
テキストではなく、選択ボックスの値が必要であることを意味します。