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

Symfony - How to fix Circular Reference

Не загружается Linux (crash)

How to logout from Zoho Desk via SAML