How to get multiple select box values using jQuery?

DEVOPS picture DEVOPS · Jul 14, 2010 · Viewed 403.8k times · Source

How to get multiple select box values using jQuery?

Answer

Darin Dimitrov picture Darin Dimitrov · Jul 14, 2010

Using the .val() function on a multi-select list will return an array of the selected values:

var selectedValues = $('#multipleSelect').val();

and in your html:

<select id="multipleSelect" multiple="multiple">
    <option value="1">Text 1</option>
    <option value="2">Text 2</option>
    <option value="3">Text 3</option>
</select>