drop-down-menumaterializemultipleselection

Materialize Multiple Select


I have a Materialize Multiple Select element. But I can't seem to find a way to retrieve the selected values. Does anybody know how you can retrieve the selected values?

Here's the look when you select it: Multiple Select active

Heres how it looks when you close it: Multiple Select inactive

But the question is how to retrieve the values inside the selector when closed.

EDIT: I am using Materialize CSS (http://materializecss.com)


Solution

  • You can get it with basic jQuery; there's nothing special about the Material markup.

    For a select like this:

    <select id="mySelect" multiple>
        <option value="1" selected>Option 1</option>
        <option value="2" selected>Option 2</option>
        <option value="2">Option 2</option>
    </select>
    

    $('#mySelect').val() will return an array of selected values: ["1", "2"]