This plugin lets you grab text the user has selected in a textarea, and this site has non-jQuery-based instructions for grabbing text the user has selected outside of a text
There's nothing wrong with copying and pasting snippets of code, that's how most people start out and you will keep doing it until you get so familiar with the snippets that you paste that you'll start modifying bits and portions or even starting from scratch by yourself.
For that particular piece of code, I don't really see anything wrong with copying it other than not relying on inline event handlers and unobtrusively adding the 'mousedown' with jQuery.