Getting an Selected Text from a Dropdownt List.

Posted by vishalneeraj-24503 under jQuery category on | Points: 40 | Views : 534
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>

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());


Comments or Responses

Login to post response