Amit Amit - 1 month ago 13
jQuery Question

Get selected key/value of a combo box using jQuery

Please, how can I get the selected key and value of a HTML select combo box using jQuery?

$(this).find("select").each(function () {
if ($.trim($(this).val()) != '') {
searchString += $.trim($(this).val()) + " "; //This gives me the key. How can I get the value also?



I assume by "key" and "value" you mean:

    <option value="KEY">VALUE</option>

If that's the case, this will get you the "VALUE":


And you can get the "KEY" like this: