Published on: 19 Oct, 2019

How to get selected option text and value in JQuery?

Tumblr Digg Google Plus

In this article, we are going to learn how to get the selected option text and value in JQuery.

Let's say we have the following select dropdown html code.

<select id="cboFruit" class="comboBox">
	<option value="">Select Fruit</option>
	<option value="Apple">Apple</option>
	<option value="Banana">Banana</option>
	<option value="Blueberry">Blueberry</option>
	<option value="Melon">Melon</option>
	<option value="Watermelon">Watermelon</option>

To get the selected text, we can use the following JQuery code. The hashtag # represents the selector id of select HTML object.

$("#cboFruit option:selected").text();

To get the selected value, we can use the built in val method.



You can see the following real demo by clicking the Get Value button to get the select option value or click the Get Text button to get selected option text value.


There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.