Created
May 1, 2011 00:21
-
-
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
This file contains 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.fn.focus_select = function() { | |
return this.each(function(){ | |
var $this = jQuery(this); | |
if ( $this.is('select') ) { | |
$this.focus() | |
} else { | |
$this.select() | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, I have been writing about this to make more ux-designer aware of this possiblity http://uxzentrisch.de/fokus-cursor-input/ (in german).