diff --git a/src/Dropdownizer.js b/src/Dropdownizer.js index 06e5df7..d16194c 100644 --- a/src/Dropdownizer.js +++ b/src/Dropdownizer.js @@ -42,6 +42,16 @@ class Dropdownizer { return this; } + /** + * Gets informations of the currently selected list item(s). + * @type {Array|Object} + */ + get selectedItem() { + let selectedItems = this._dropdowns.map(dropdown => dropdown.selectedItem); + + return (selectedItems.length > 1 ? selectedItems : selectedItems[0]); + } + /** * Listens for change events. * @param {Function} callback The callback function to execute when a list item changes. @@ -342,6 +352,14 @@ class Dropdownize { return out; } + /** + * Gets informations of the currently selected list item. + * @type {Object} + */ + get selectedItem() { + return this._callbackArgs(this._listItems[this._lastSelectedIndex]); + } + /** * Listens for change events. * @param {Function} callback The callback function to execute when a list item changes.