A jQuery plugin for custom select elements.
dropdown.js
dropdown.css
jQuery
core.js
scrollbar.js (optional)
touch.js (optional, for scrollbar)
To customize a select element, simply apply the plugin to the target element:
$("select").dropdown();<select>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
React to changes to the element's value by listening for the standard change event:
$("select").on("change", function() {
var value = $(this).val();
});Updated the element's value externally by triggering the standard change event:
$("select").val(1).trigger("change");Note: If the select is too close to the bottom edge of the body tag, the dropdown options will "flip" and display above the handle.
Set instance options by passing a valid object at initialization, or to the public defaults method. Custom options for a specific instance can also be set by attaching a data-dropdown-options attribute to the target elment. This attribute should contain the properly formatted JSON object representing the custom options.
| Name | Type | Default | Description |
|---|---|---|---|
bottomEdge |
int |
0 |
|
cover |
boolean |
false |
Cover handle with option set |
customClass |
string |
'' |
Class applied to instance |
label |
string |
'' |
Label displayed before selection |
external |
boolean |
false |
Open options as links in new window |
links |
boolean |
false |
Open options as links in same window |
mobile |
boolean |
false |
Force desktop interaction on mobile |
theme |
string |
"fs-light" |
Theme class name |
trim |
int |
0 |
## Methods
Methods are publicly available to all active instances, unless otherwise stated.
Closes target instance.
$(".target").dropdown("close");Extends plugin default settings; effects instances created hereafter.
$.dropdown("defaults", { ... });| Name | Type | Default | Description |
|---|---|---|---|
options |
object |
{} |
New plugin defaults |
Removes plugin instance.
$(".target").dropdown("destroy");Disables target instance or option.
$(".target").dropdown("disable", "1");| Name | Type | Default | Description |
|---|---|---|---|
option |
string |
null |
Target option value |
Enables target instance or option.
$(".target").dropdown("enable", "1");| Name | Type | Default | Description |
|---|---|---|---|
option |
string |
null |
Target option value |
Opens target instance.
$(".target").dropdown("open");Updates instance.
$(".target").dropdown("update");## CSS
| Class | Type | Description |
|---|---|---|
.fs-dropdown-element |
element |
Target element |
.fs-dropdown |
element |
Base widget class |
.fs-dropdown.fs-dropdown-multiple |
modifer |
Indicates multi-selected element |
.fs-dropdown.fs-dropdown-cover |
modifer |
Indicates cover positioning |
.fs-dropdown.fs-dropdown-bottom |
modifer |
Indicates bottom positioning |
.fs-dropdown.fs-dropdown-disabled |
modifer |
Indicates disabled state |
.fs-dropdown.fs-dropdown-open |
modifer |
Indicates open state |
.fs-dropdown.fs-dropdown-focus |
modifer |
Indicates focus state |
.fs-dropdown-selected |
element |
Handle item |
.fs-dropdown-options |
element |
Options container |
.fs-dropdown-group |
element |
Option group label |
.fs-dropdown-item |
element |
Option item |
.fs-dropdown-item.fs-dropdown-item_placeholder |
modifier |
Indicates placeholder item |
.fs-dropdown-item.fs-dropdown-item_selected |
modifier |
Indicates selected item |
.fs-dropdown-item.fs-dropdown-item_disabled |
modifier |
Indicates disabled item |