diff --git a/js/bootstrap-select.js b/js/bootstrap-select.js index 6c12119eb..d183e4735 100644 --- a/js/bootstrap-select.js +++ b/js/bootstrap-select.js @@ -1441,7 +1441,8 @@ this.sizeInfo.selectWidth = this.$newElement[0].offsetWidth; text.className = 'text'; - a.className = 'dropdown-item ' + this.$element.find('option')[0].className; + var optionElements = this.$element.find('option'); + a.className = 'dropdown-item ' + (optionElements.length === 0 ? '' : optionElements[0].className); newElement.className = this.$menu[0].parentNode.className + ' ' + classNames.SHOW; newElement.style.width = this.sizeInfo.selectWidth + 'px'; if (this.options.width === 'auto') menu.style.minWidth = 0;