David Garcia
David Garcia

Reputation: 2696

Displaying html data in form

I have in my database a column that stores html data i.e <p>this is a test</p> and I am loading that data into a javascript form field, however, the html tags are not being parsed properly.

They are being displayed such as;

&lt;p&gt;This is a test&lt;/p&gt;

Can someone give me a hint as to what I am doing wrong please.

Upvotes: 0

Views: 58

Answers (2)

Amy
Amy

Reputation: 4032

Parse your text using .html function

var text= $('<textarea />').html("&lt;p&gt;This is a test&lt;/p&gt").text();
alert(text);

DEMO

Upvotes: 1

Tom B
Tom B

Reputation: 11

Looks like the tags are being saved as their HTML entity equivalent. You'll have to convert them to their actual character if that's what you require.

Upvotes: 0

Related Questions