javascript - html() & text() ignoring \n and <br /> -
i don't understand why happening, got description of app google play store, in form of json, using jquery add description div, instead of printing is, gives block of paragraph , ignores \n or <br />
tag.
var description = json.description; alert(description);
when alert description, shown above, there proper paragraph format next line[\n] included want it, when add required div either html()
or text()
, ignores next line \n
$('#appname').html(description)
;
i tried replace next line
tags, still result same, don't know why
var test = description.replace(/\s\n+/g, '<br />'); $('#appname').html(description)
try this
var test = description.replace(/\n/g, '<br />'); $('#appname').html(test );
your regex not work if there no white space before newline character. dont need put + /g replace new line characters.
Comments
Post a Comment