diff --git a/ui/selectmenu.js b/ui/selectmenu.js index dad7a1b40..db2cea712 100644 --- a/ui/selectmenu.js +++ b/ui/selectmenu.js @@ -90,7 +90,7 @@ return $.widget( "ui.selectmenu", { ); // Associate existing label with the new button - this.labels = this.element.labels(); + this.labels = this.element.labels().attr( "for", this.ids.button ); this._on( this.labels, { click: function( event ) { this.button.focus(); @@ -423,7 +423,8 @@ return $.widget( "ui.selectmenu", { return; } - if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) { + if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + + $.ui.escapeSelector( this.ids.button ) ).length ) { this.close( event ); } }