How to Get Value of Selected Option from Select Box in jQuery

Getting selected option value in javascript jquery is a common thing in our software developer life. In this example, I will share this source code with my codecheef readers that how we can get jquery get value of the selected option.

I will also show jquery get selected option text. So if you don't know how to get selected option value from select box using jquery, then this example is for you. 

We can do it using jQuery in many ways. I will here share with you some helpful examples of how to get selected option value from the select box. Let's see the example code:

Example 1

 

Example 2

 

If you need to get a text from option, then follow this code:

$(document).ready(function() {
  $("#submit").click(function() {
    var value = $("#myselection option:selected");
    console.log(value.text());
  });
})

 

Read also: How to Convert 24 Hours to 12 Hours in JavaScript

 

Hope this code will help you.

 

Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js