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.

1 Answer 1

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

And live demo as always.

Sign up to request clarification or add additional context in comments.

2 Comments

It doesn't work when the text has apostrophes. Doesn't work when it has white spaces.
@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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.