jqueryhtmlmultiple-selectmultiple-select-query

Get selected option text and not value


I have a multiple select and I want to get selected text and not the value.

What I mean is this :

<option value="1100"> MH-03-P-9429</option>

And I want to get MH-03-P-9429 as selected text, but when I do

$("#usersDropDown").multipleSelect('getSelects')

I get output as 1100 as shown in fiddle.

Multiple Select Issue

Can anyone help me out here ?

How can I get selected option text and not the value ?

NOTE : .text() and .val() doesn't work against getSelects


Solution

  • Try this:

    $("#usersDropDown").multipleSelect({
      placeholder: "Select Users",
      selectAll: true,
      width: "100%",
      filter: true,
    });
    $("#usersDropDown").on('change',function ()
    {
      var getSelected = $("#usersDropDown").multipleSelect('getSelects', 'text');
      alert(getSelected)
    });