Bad Programmer Bad Programmer - 2 months ago 10
jQuery Question

How to get currently selected value of a multiple select with Jquery

I have a multiple select dropdown box. I need to make an ajax call every time an item is selected, but am having a problem getting the specific value from the select menu. Instead of retrieving the currently selected value, I get an array of all selected values. How can I get the current selected value with JQuery?

Answer

OK, just figured it out:

$(this).val();

Previously I was using $('#id').val() and that was returning the array. $(this).val() will give you the current selected value.