John Davidson

javascript - selectize.js select dropdown show by default opened


I'm using selectize.js for my search form and want to show select list opened by default.

<select id="select-state" name="state[]" multiple class="demo-default" placeholder="Select Models">
<option value="">Select Models</option>
<option value="Tanzania">Tanzania</option>
<option value="Kenya">Kenya</option>
<option value="Uganda">Uganda</option>
<option value="Asia">Asia</option>
<option value="Malaysia">Malaysia</option>
<option value="Japan">Japan</option>
maxItems: 5

I have tried different methods but none of them are working.
By jQuery



<style>.selectize-dropdown{ display:block!important; visibility:visible!important;}</style>

My Answer:
You can achieve this by using the `open` method provided by selectize.js. Here's an example code snippet to show the select dropdown opened by default:

// Initialize selectize
var $select = $('#my-select').selectize({
// options

// Get selectize instance
var selectize = $select[0].selectize;

// Open the dropdown;

Make sure to replace `#my-select` with the ID of your select element. This code will open the select dropdown by default when the page loads.

Rate this post

3 of 5 based on 2650 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us