0

I want to display option in my dropdown without value, but select 2 prohibits it.

<select name="searchcategory[]" multiple="multiple" class="js-example-basic-multiple">
          <option value=''>All Category</option>
</select>

my select2 js

$(".js-example-basic-multiple").select2({
    placeholder: "Choose category",
});
I.Jokhadze
  • 456
  • 2
  • 8
  • 27

2 Answers2

0

Use selected in the <option selected> tag like this:

<select name="searchcategory[]" multiple="multiple" class="js-example-basic-multiple">
  <option value='' selected>All Category</option>
</select>

Hope this helps!

Saumya Rastogi
  • 13,159
  • 5
  • 42
  • 45
0

To reset simply call again select2

$(".js-example-basic-multiple").select2("val", "");

Reference from: Reset select2 value and show placeholder

Community
  • 1
  • 1
Tee
  • 9
  • 2