html() & text() ignoring \n and <br />

I don’t understand why this is happening, basically i got some description of some app from Google play store, in the form of JSON, now i am using jQuery to add the description into some div, but instead of actually printing as it is, it gives a block of paragraph and ignores \n or <br /> tag.

var description = json.description;

When I alert this description, as shown above, there is proper paragraph format with next line[\n] included just like I want it, but when I add it to the required div with either html() or text(), it ignores the next line \n


I tried to replace the next line with the
tags, but still the result was same, I don’t know why

var test = description.replace(/\s\n+/g, '<br />');

1 thought on “html() & text() ignoring \n and <br />”

Leave a Comment