A
A
Artem Kondratsky2019-03-15 20:58:06
JavaScript
Artem Kondratsky, 2019-03-15 20:58:06

How do I move to the next line?

I get the following from the back:
(this is only an important line)

....
"about": "......\nПомимо этого я занимаюсь профессионально фотографией и видеосъемкой."
.....

How to make a line break if .replace('\n', '<.br.>') doesn't work?
I tried to put instead of .replace - <.pre.>, there is a transfer, but a vertical and horizontal scrollbar appears + the absence of any styles.
Thanks in advance to everyone who helps.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2019-03-16
@kondrackii

You can use css, set the white-space property to the element with the text: pre-wrap;
In this case, all line breaks '\n' will be taken into account.

V
Vladislav, 2019-03-15
@ghostiam

Google:
js replace all
Find:

String.prototype.replaceAll = function(search, replace){
  return this.split(search).join(replace);
}

// Используем
"текст".replaceAll('\n', '<br>')

Or simply: replace "text".replace('\n', '<.br.>') with
"текст".split('\n').join('<br>')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question