Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
192
rated 0 times [  193] [ 1]  / answers: 1 / hits: 67029  / 13 Years ago, thu, september 8, 2011, 12:00:00

I have HTML data stored in database which I wish to display as is. It keeps converting
tags to <br /> which is a behavior I do not want. I have tried playing with javascript replace and still I am unable to convert it to regular HTML.



    var venueaddress = msg.result[0].venueaddress;
var venueaddress2 = venueaddress.replace([newline], <br />);

alert(venueaddress2); //shows <br />


$(#venueaddress).text(venueaddress2); //lets now display it on the browser

<li><h3>Venue Address</h3><p><strong> <span id=venueaddress></span> </strong></p></li>


However when it renders on browser, it has the <br /> and there fore there is no line break.


More From » html

 Answers
41

Your problem is with



$(#venueaddress).text(venueaddress2);


you should use



$(#venueaddress).html(venueaddress2);


Text will encode any html character and will display it in span as encoded, html will not.


[#90197] Wednesday, September 7, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tomas

Total Points: 165
Total Questions: 111
Total Answers: 103

Location: Maldives
Member since Tue, Dec 21, 2021
3 Years ago
tomas questions
Thu, Jan 27, 22, 00:00, 2 Years ago
Mon, May 10, 21, 00:00, 3 Years ago
Tue, Jan 5, 21, 00:00, 3 Years ago
;