-1

I have a drop down where user can select multiple options

I am trying to get all the options selected .I tried the following code snippet but does not seem to work.

can some one please help me on this

<select id="categorie" class="form-control selectpicker" multiple></select> 
$("select option:selected") 
Geeky
  • 7,420
  • 2
  • 24
  • 50
user6045391
  • 51
  • 1
  • 7

1 Answers1

0

If you are trying to get all the selected option values of multiple select drop down,you could do something like this

$(function() {
  var optionsSelected = $('select').find('option');
  $("#click").on('click', function() {
    var selectedOptions = $('select').children('option:selected');
    selectedOptions.each(function(option) {
      console.log(selectedOptions[option].innerHTML);
    });
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="categorie" class="form-control selectpicker" multiple>

  <option>123</option>

  <option>12</option>

  <option>21</option>
  <option>14</option>

  <option>12</option>

  <option>121</option>

  <option>112</option>

  <option>201</option>
</select>

<input type="button" id="click" value="click">

Hope it helps

Geeky
  • 7,420
  • 2
  • 24
  • 50