jQuery Get Selected Option Value on Select

In this tutorial, Learn how to get selected option value of a select dropdown using jQuery. The short answer is to use the change() event with val() function to find the selected option value on select.

You can also use the button click event using click() function of jQuery to find the dropdown selected option values. With the below examples, you can easily find a single select box option value and multiple select box option values.

Let’s find out how to get single-selected option values and multiple-selected options values with the examples given below.

Method 1: jQuery Get Selected Option Value Using change() and val() Function

If you want to get the value of the selected option for the single select box, you have to use the change() function of jQuery to trigger the code on the dropdown option change. After that, inside this function, use the val() to get the value of the select box.

Output


Choose your option from the select box given above.

Select the option from the select box given above. You will get the value of the selected option in the alert message box. This is the simple yet efficient script to get the value of the selected option on dropdown select.

If you want to get the select option value on button click, you can use the below 2nd method given below.

Method 2: On Button Click Event Using click() and val() Function

To find the select option value on the button click, you can use the click() function for the button click event. Inside this function, use the val() function to get the selected option value.

Output


Choose your option from the select box given above.

The above example contains the button element and the select dropdown. You have to first select your required option from the dropdown. After that, click the button to get your selected value in an alert box.

If you want to find the multiple selected option from the multiple select boxes, then keep reading to find the answer to how to get multiple select boxes selected option value using jQuery.

How to Get Multiple Select Box Option Value on Multiple Select Using jQuery

In addition to the above example, you can find the values for the multiple selected options. For this, you have to use the multiple select boxes by using the attribute multiple in the HTML <select> tag.

The script is the same as the first method given above that uses the change() to get the option change events. But the script finds the change event of the multiple select boxes and gives the values in an array format using val() function.

Output

Note: To select multiple value press ctrl+ mouse and click the option.

Choose multiple options from the select box given above.

Now, press both the control key of the keyboard and the left mouse button to select multiple values. You will get the multiple values in an array format in the alert message box.

You May Also Like to Read