html - Can I insert some string at every other line using javascript? -


Suppose I have a big wall of text, which I pasted on my page inside a device with the ID "story". Each paragraph is actually on one line in the html file, and each paragraph is separated from one line. I want to make text wall more readable by using bootstrap. I have set CSS in a blog-like format, if a paragraph is different, then dynamically & lt; / P & gt; & Lt; P & gt; Add ?

  var paragraph = "your text" .split (/ \ n \ s * \ n /); // paragraphs are different from (var i = 0; i & lt; paragraph.lamp; i ++) {// a line, we need two \ n here. Var p = document.createElement ("p"); P.innerHTML = paragraphs [i]. Trim (); Document.querySelector ("#Three") appendChild (P). } // ============= To get the text of an element (with new lines), you can do: document.querySelector ("# story"). ChildNodes [0] .wholeText;   

Maybe something like this?

What you should not do is transferring text inside the string and dumping it into the right domain. This is bad behavior that is why I am here & lt; / P & gt; & Lt; P & gt; . Instead of replacing lines with p element. >

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -