Enhanced Dropdown Select In Pure JavaScript – LC-select
1. Download and include the LC-select’s files on the page.
<!-- Light Theme --> <link href="themes/light.css" rel="stylesheet" /> <!-- OR Dark Theme --> <link href="themes/dark.css" rel="stylesheet" /> <!-- Core JavaScript --> <script src="lc_select.js"></script>
2. Just initialize the plugin on your existing select element and done.
new lc_select(document.querySelector('select'), {
// options here
}); 3. Add custom images to options using the data-image attribute.
<select name="simple">
<optgroup label="javascript" data-image="js.svg">
<option value="vue" data-image="vue.svg">Vue.js</option>
<option value="react" data-image="react.png">React</option>
<option value="angular" data-image="angular.png">Angular</option>
</optgroup>
...
</select> 4. Customize the placeholder for the select.
<select ata-placeholder="Select A Language...">
<optgroup label="javascript" data-image="js.svg">
<option value="vue" data-image="vue.svg">Vue.js</option>
<option value="react" data-image="react.png">React</option>
<option value="angular" data-image="angular.png">Angular</option>
</optgroup>
...
</select> 5. Determine whether to enable the live search functionality. Default: true.
new lc_select(document.querySelector('select'), {
enable_search : true,
min_for_search : 7, // 7 results to show
}); 6. Determine the maximum number of options allowed to select in a multi select.
new lc_select(document.querySelector('select'), {
max_opts: 6
}); 7. More default configs.
new lc_select(document.querySelector('select'), {
// defines the wrapper width
wrap_width: 'auto',
// additional CSS classes
addit_classes: [],
// prepend an empty option using placeholder text
pre_placeh_opt : false,
// custom labels
labels: [
'search options',
'add options',
'Select options ..',
'.. no matching options ..',
],
// callback function
on_change: function(new_value, target_field) {
// do something
}
}); 8. API methods.
// re-sync
const resyncEvent = new Event('lc-select-refresh');
select.dispatchEvent(resyncEvent);
// destroy
const destroyEvent = new Event('lc-select-destroy');
select.dispatchEvent(destroyEvent); v1.3.0 (09/12/2025)
v1.2.0 (06/27/2025)
v1.1.11 (06/25/2025)
v1.1.10 (03/04/2025)
v1.1.9 (03/01/2025)
v1.1.8 (06/06/2023)
v1.1.7 (10/18/2022)
v1.1.6 (06/15/2022)
v1.1.5 (09/21/2021)
v1.1.4 (06/30/2021)
v1.1.3 (03/18/2021)
The post Enhanced Dropdown Select In Pure JavaScript – LC-select appeared first on CSS Script.
Activist investor Oasis Management Company has acquired a 8.86% in Japanese media powerhouse Kadokawa, parent…
March 19, 2026 At 67, Ferlyn Hofer just got a big glimpse of how the…
AUSTIN, Texas, Mar. 19, 2026, CyberNewswire—SpyCloud, the leader in identity threat protection, today released its…
JoinBond.xyz – Namecheap customer – (United States) Forward-thinking developers use .xyz domains to drive innovation…
Just days ago, a game came out whose unlikely premise has already drawn a good…
The LPGA Tour will bring the 2026 Mizuho Americas Open to Mountain Ridge Country Club…
This website uses cookies.