0

I have stored text in HTML format to database and want to dynamically show in textarea or something like this.

This is textarea

<textarea class="FormElement" name="txtObject" id="term" style="width: 320px; height: 250px;"></textarea>

and set value with javascript

$('[name=txtObject]').val(row.Text);

but get <strong>Text message</strong> I want to get Text message.

Can anybody help me?

tungi
  • 15
  • 1
  • 8

2 Answers2

1

This is not possible to do with a textarea. The result you want to achieve is possible with a content editable div , like so :

<div contenteditable="true"></div>
Brovoker
  • 896
  • 5
  • 16
  • If anyone is concerned with backwards compatability, the `contenteditable` runs on all modern browsers back to (and including) IE8 - http://caniuse.com/#search=contenteditable – Fizk Mar 25 '14 at 10:33
0

A textarea is just supposed to be used to enter unformatted text. If you just want to display the text, add it to a div instead, should work with $('#mydiv').html(row.Text). If you want a more rich text editor I'd suggest to google around for one that is suitable for you.

TinyMCE seems to be a resonable alternative.

dotmartin
  • 531
  • 1
  • 4
  • 25