How to Get Value or Selected Option in Select Dropdown List Using Javascript and jQuery Full Tutorial For Beginners

You are currently viewing How to Get Value or Selected Option in Select Dropdown List Using Javascript and jQuery Full Tutorial For Beginners

 

Welcome folks today in this blog post we will be talking about how to get value of selected option in dropdown list in javascript. All the source code will be given below.

 

 

Get Started

 

First we will do in javascript and we will use simple value property to get the selected option from dropdown list

In order to get started we need to create a index.html file and copy paste the following code

 

 

 

 

If you run this code and as the form submits then it will console log the selected option in the console with the help of value property in javascript

 

Now if you want to get the whole option which was selected you can get it with the help of selectedIndex property in javascript like this

 

 

 

 

 

 

 

 

If you want to get the label of selected index in dropdown list in javascript you can do like this with the help of text property

 

 

 

 

 

 

 

 

Get Value of Selected Option in jQuery

 

 

 

Now we will look at how to do the same in jQuery

 

 

 

 

This is the simple select box in html we have provided a id to it So now to get the value of selected option we will use val() method again in jquery

 

 

 

 

In order to get the text property of the selected option we will use the the text method

 

 

 

 

Leave a Reply