Plugin for customisation <select>
element in pure JavaScript.
It's simple as that:
- Add the minified file in your html document;
- Initialize the plugin by this way:
new Select({
selector: '#select'
});
- Also the callBack option is available:
new Select({
selector: '#select',
callBack: function() {
console.log('Hello, new Select');
}
});
- If you need to use value of selected item - it's easy:
new Select({
selector: '#select',
callBack: function(item) {
console.log('You pick item with a value: ' + item.value;
}
});
- During the initialisation the plugin gets all attributes of <option> tag so you can easily get it's value by native js method:
new Select({
selector: '#select',
callBack: function(item) {
console.log('You pick item with a value: ' + item.el.getAttribute('data-value');
}
});