Get the value of a dropdown in jQuery
$('#Crd').val()
will give you the selected value of the drop down element. Use this to get the selected options text.
$('#Crd option:selected').text();
The best way is to use:
$("#yourid option:selected").text();
Depending on the requirement, you could also use this way:
var v = $("#yourid").val();
$("#yourid option[value="+v+"]").text()
This has worked for me!
$('#selected-option option:selected').val()
Hope this helps someone!
If you're using a <select>
, .val()
gets the 'value' of the selected <option>
. If it doesn't have a value
, it may fallback to the id
. Put the value you want it to return in the value
attribute of each <option>
Edit: See comments for clarification on what value
actually is (not necessarily equal to the value
attribute).