There is a code that displays text from a file in a block:

setInterval(function() { $.get("text.txt", function(data) { $("#content").text(data); }); }, 2000); 

Text.txt file:

 пример1 пример2 

The script displays the text in one line: example1 example2. How can I make the text displayed strictly as in the file?

    2 answers 2

    as an option

     setInterval(function() { $.get("text.txt", function(data) { $("#content").html('<pre>' + data + '</pre>'); }); }, 2000); 
    • Hi, XSS (although in the case of the author maybe not critical) - andreymal

    Try adding a css rule to the item. in which you output the text white-space: pre-line .

    Or use js on the similarity of string replacedText = row.Text.Replace("\n", "<br />");