Nate Pet Nate Pet - 1 year ago 75
jQuery Question

Get the value of a dropdown in jQuery

I have a drop down that has an 'ID, Name' Pair.


Jon Miller

Jim Smith

Jen Morsin

Jon MIller has ID of 101

Jim Smith has ID of 102

Jen Morsin has ID of 103

When I do the followng:

var arNames = $('#Crd').val()

and I select Jon Miller, I get 101. I'd like to get Jon Miller though.

Answer Source

$('#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();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download