SELECT element.
Handle changes in value:
const mySelect = select(`#mySelect`, (newValue) => { console.log(`Value is now ${newValue}`);}); Copy
const mySelect = select(`#mySelect`, (newValue) => { console.log(`Value is now ${newValue}`);});
Enable/disable:
mySelect.disabled = true / false; Copy
mySelect.disabled = true / false;
Get currently selected index or value:
mySelect.value / mySelect.index Copy
mySelect.value / mySelect.index
Is the currently selected value a placeholder?
mySelect.isSelectedPlaceholder Copy
mySelect.isSelectedPlaceholder
Set list of options
// Adds options, preselecting `opt2`.mySelect.setOpts([`opt1`, `opt2 ...], `opt2`); Copy
// Adds options, preselecting `opt2`.mySelect.setOpts([`opt1`, `opt2 ...], `opt2`);
Select an element
mySelect.select(1); // Select second itemmySelect.select(1, true); // If true is added, change handler fires as well Copy
mySelect.select(1); // Select second itemmySelect.select(1, true); // If true is added, change handler fires as well
Query (eg #id) or element
#id
Optional
Callback when a selection is made
Options
SELECT element.
Handle changes in value:
Enable/disable:
Get currently selected index or value:
Is the currently selected value a placeholder?
Set list of options
Select an element