Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 937
Rockernaap Avatar asked Nov 17 '15 14:11

Rockernaap


People also ask

What is Material_select?

<mat-select> is a form control for selecting a value from a set of options, similar to the native <select> element.

Is materialize responsive?

Materialize provides a container for embedded videos that resize them responsively. To do this, wrap them with the containing div, which adds the class video container. And the third class is a responsive video.

What is materialize in CSS?

Materialize CSS is a design language that combines the classic principles of successful design along with innovation and technology. It is created and designed by Google. Google's goal is to develop a system of design that allows for a unified user experience across all its products on any platform.


1 Answers

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"]

like image 139
kielni Avatar answered Oct 02 '22 12:10

kielni