Using Javascript I have the following issue, when displaying data on a web page.
The code goes like this:
myString.replace('\n', '<br/>');
I suppose the purpose is clear, I want to replace the '\n' linefeed marker by the < br / > tag, doing the same thing but in HTML.
The problem is:
Starting with the string: abc\nXYZ instead of getting abc< br />XYZ like I would expect, I end up with abc & lt;br/& gt;XYZ. This is of course not what I want, because the effect is not the same.
What is the proper work around?
');` gives me `"abc
XYZ"` when I log the result in the console. Why do you think you get `abc & lt;br/& gt;XYZ` ? Are you doing anything else after? – Ben Lorantfy Sep 27 '18 at 03:42
XYZ in the source and a jump to the next line in the web page. – Michel Sep 27 '18 at 03:47
`. so this conversion may not be needed at all. – apple apple Sep 27 '18 at 03:59
`. – Michel Sep 27 '18 at 16:35