Hello friends this is my code:
<select id='first'>
<option value='1'> First </option>
<option value='2'> Second </option>
<option value='3'> Three </option>
</select>
This is my select2 code:
$("#first").select2();
Below is code for getting selected value.
$("#first").select2('val'); // It returns first,second,three.
This is return a text like first,second,three
and I want to get 1,2,3
.
Means I need the value of select box, not text.
$("#first").val(); // this will give you value of selected element. i.e. 1,2,3.