[jQuery] Paste text at selection in DIV

[jQuery] Paste text at selection in DIV


I'd like to have a way to paste text into a DIV at the selection point
via a link. Something like this:
<a href="pasteText('test');">Paste Test</a>
<div id="divPaste">This is my text</div>
Say I have the above and I highlight "text" with the mouse. How could
I make the Paste Test link overwrite the "text" with "test"? Really
what I'm trying to accomplish is done at this link, but I need to do
the same thing to a DIV and not a textarea. http://skfox.com/jqExamples/insertAtCaret.html
Ideas on how to do that?