Below code returns the
Inner Text value of an item in a select list.
Suppose,we have Employee dropdownlist,which contains the list of employees as shown below:-
<select Id ='ddl_employee'>
<option value = '1'>Vishal</option>
<option value = '2'>Vinod</option>
<option value = '3'>Sarita</option>
<option value = '4'>Pramod</option>
</select>
Here,
1 is a Value and Vishal is a Text and so on.So to get a Text Vishal,we will write below jQuery code as:-
finction getText()
{
alert($("#ddl_employee option[value='1']").text());
alert($("#ddl_employee option[value='2']").text());
}
Output:-
Vishal
Vinod