Created
August 4, 2010 14:54
-
-
Save corydeppen/508253 to your computer and use it in GitHub Desktop.
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
// Select text inside an input field on user click or focus | |
// http://jquery-howto.blogspot.com/2009/04/select-text-in-input-box-on-user-select.html | |
$("#myInputField").focus(function(){ | |
// Select input field contents | |
this.select(); | |
}); | |
// Add this behavior to all text fields | |
$("input[type=text]").focus(function(){ | |
// Select field contents | |
this.select(); | |
}); | |
// Selects all text content of textareas if and only if it’s value has changed from the original one | |
$("textarea").focus(function(){ | |
// Check for the change | |
if(this.value == this.defaultValue){ | |
this.select(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment