diff --git a/src/jquery.selectric.js b/src/jquery.selectric.js
index 083a368..08728a3 100644
--- a/src/jquery.selectric.js
+++ b/src/jquery.selectric.js
@@ -173,6 +173,19 @@
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
},
+ /**
+ * Returns new unique id with 'sel-' prefix to use with aria-owns relationships
+ * @return {string} The new unique id generated
+ */
+
+ randomId: function() {
+ var new_id = false;
+ while ( !new_id || null != document.getElementById( new_id ) ) {
+ new_id = 'sel-' + (0|Math.random()*9e6).toString(36);
+ }
+ return new_id;
+ },
+
/**
* Calls the events registered with function name.
*
@@ -226,13 +239,33 @@
// Get classes
_this.classes = _this.getClassNames();
+ // create random prefix for ids to use in aria-owns, aria-controls, etc. properties
+ _this.random_prefix = _this.utils.randomId();
+ // find label if it exists
+ var original_label_id = false;
+ if ( _this.$element.attr( 'id' ) ) {
+ var $original_label = $( 'label[for="' + _this.$element.attr( 'id' ) + '"]' );
+ if( 0 < $original_label.length ) { // if a label exists, let's use it for aria-labelledby
+ if ( !$original_label.attr( 'id' ) ) { // if it doesn't have an id, we need to give it one
+ $original_label.attr( 'id', _this.random_prefix + "-labelledby" );
+ }
+ original_label_id = $original_label.attr( 'id' );
+ }
+ }
+
// Create elements
var input = $('', { 'class': _this.classes.input, 'readonly': _this.utils.isMobile() });
var items = $('