rkamun1
rkamun1

Reputation: 338

jQuery: Inserting formatted text into a textarea

I have a drop-down list which causes a text-area to populate with different text depending on what's selected. I have this part working fine, but I'm not able to format the text to show paragraphs. using regular html, just causes it to be printed out.

Does any one know can I create paragraphs, etc?

Thanks Guys!!

Upvotes: 2

Views: 1903

Answers (2)

Ayman Safadi
Ayman Safadi

Reputation: 11552

<p> is an HTML tag. <textarea> doesn't recognize HTML tags, unless you're using some kind of rich-text editor.

That said, you can create line breaks in your <textarea> using \n like this:

$('#my-text-area').text('foo\nbar');

Upvotes: 0

Josh
Josh

Reputation: 12566

You'll need to use some sort of rich text editor, like CKEditor, or, use newlines \n. The <p> will be interpreted literally in a textarea.

Upvotes: 1

Related Questions