Skip to content

Instantly share code, notes, and snippets.

@danott
Created October 12, 2010 17:31
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 danott/622573 to your computer and use it in GitHub Desktop.
Save danott/622573 to your computer and use it in GitHub Desktop.
/* While implementing shorturls, I wanted to make the url easily copyable.
* To do this, I placed it in a text input field, that was styled like the copy text
* of the page. To ease the copying process, I wanted to select the entire contents
* of the text on focus. Webkit browser would select on focus, but would then quickly deselect.
* This is the workaround I came up with. */
// Meant to select <input type="text" class="short-url" value="http://danott.us/s/123" />
$(".short-url").focus(function(e){
this.select();
}).mouseup(function(e){
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment