Renish Khunt Renish Khunt - 9 months ago 104
jQuery Question

jQuery select2 get value of select tag?

Hello Friends this is my code.

<select id='first'>
<option value='1'>First</option>
<option value='2'>Second</option>
<option value='3'>three</option>

this is my select2 code.


below is code for getting selected value.

$("#first").val(); //it return 1,2,3. this is not return anything when i used select2 plugin.
$("#first").select2('val'); // it return first,second,three

this is return a text like
and i want to get

means i need a value of select box not text please help.

$("#first").val(); // this will give you value of selected element. i.e. 1,2,3.