Skip to content

Instantly share code, notes, and snippets.

@gr2m
Created May 1, 2011 00:21
Show Gist options
  • Save gr2m/950125 to your computer and use it in GitHub Desktop.
Save gr2m/950125 to your computer and use it in GitHub Desktop.
$('input, select').focus_select() will focus the <select> and select the <input>. select does not work on <select>s
jQuery.fn.focus_select = function() {
return this.each(function(){
var $this = jQuery(this);
if ( $this.is('select') ) {
$this.focus()
} else {
$this.select()
}
})
}
@tordans
Copy link

tordans commented Jun 3, 2011

Thanks, I have been writing about this to make more ux-designer aware of this possiblity http://uxzentrisch.de/fokus-cursor-input/ (in german).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment