Skip to content

Instantly share code, notes, and snippets.

@mjlescano
Created October 21, 2014 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjlescano/1214adceb9ae1b8b0887 to your computer and use it in GitHub Desktop.
Save mjlescano/1214adceb9ae1b8b0887 to your computer and use it in GitHub Desktop.
Plugin to open the dropdown of a select element
/*
* jQuery openSelect
*
* Matías Lescano | @touteo
* Licensed under the MIT license
*/
;(function($){
$.fn.openSelect = function(options){
return this.each(function(){
var select = this
if( document.createEvent ){ // all browsers
var e = document.createEvent('MouseEvents')
e.initMouseEvent('mousedown', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
select.dispatchEvent(e)
} else if( select.fireEvent ){ // ie
select.fireEvent('onmousedown')
}
})
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment