HTML - How to add placeholder to dropdown (select) with selectpicker

First time in my life I needed to add placeholder for dropdown O.o I even didn`t know that it exists.

But, anyway, I need to implement this case. I selected selectpicker from bootstrap to have ability to use live searching in dropdown.

HTML for adding dropdown:

<select class="dropdown" data-live-search="true">
    <option class="hide" value="" disabled selected hidden>Placeholder</option>
    <option value="option1">Option 1</option>
</select> 

Javascript:

const select = $('select').selectpicker();
$('.dropdown').on('click', function () {
	$('.dropdown').find('.hide').hide();
});

Comments

Popular posts from this blog

Idea PhpStorm - How to fix bugs with incorrect code Inspections and Autocomplete

Symfony - Twig - How to check on instanceof class object

CSS Как прикрепить слой (div) к краю