0

Basically the function will be similar to the "quote" function on most forums. I need to click a button to grab some text and paste that into a textarea box.

I've tried some things and they work, however, they don't work with everything. For example, they don't work when the text that I need to grab has white spaces or apostrophes or if the text is very long. Any help?

I've tried most of the solutions outlined in this thread: Insert text into textarea with jQuery and they do not work.

Community
  • 1
  • 1
kevinkt
  • 735
  • 12
  • 24

1 Answers1

3
var element = $('#idofyourdomelement');
element.val(element.val() + ' foo bar added');

And live demo as always.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • It doesn't work when the text has apostrophes. Doesn't work when it has white spaces. – kevinkt May 04 '11 at 06:17
  • @user594623, which text? The one in the textarea or theone you are adding to? Because as you can see in the live demo I provided there are white spaces in both and it works. I've also tested with apostrophes and it worked. So maybe you can show your *non-working* code? – Darin Dimitrov May 04 '11 at 06:25