Created
October 21, 2014 13:48
-
-
Save mjlescano/1214adceb9ae1b8b0887 to your computer and use it in GitHub Desktop.
Plugin to open the dropdown of a select element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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