what is the best way to do this in jQuery? This should be a fairly common use case.
- User selects text in a textarea
- He clicks on a link
- The text in the link replaces the selected text in the textarea
Any code will be much appreciated – I am having some issues with part 3.
Here’s how you can do it, in all major browsers. I’ve also got a jQuery plug-in that includes this functionality. With that, the code would be
Here’s a full stand-alone solution: