May 4, 2014 by Nitesh

How To Select Text and Value from Drop Down List in jQuery


This post is a very simple tip for getting the selected text and selected value from a drop down list using jQuery. A very common usage and we use it in almost every project that we do. To start with, let us consider we have a drop-down list with ID “numbers”. The DOM structure of the select list something looks like below.

<select id="numbers">
   <option value="1">One</option>
   <option value="2">Two</option>
   <option value="3">Three</option>
   <option value="4">Four</option>

To get the selected text and value for this drop down list, we can use the below piece of code.

var text = $("#numbers option:selected").text();
var value = $("#numbers option:selected").val();
alert("Selected text=" + text + " Selected value= " + value);

Keep learning and sharing!


Support us!

If you like this site please help and make click on any of these buttons!

Powered by WordPress Popup