2016-07-08 13 views
2

Ich möchte einen langen Absatz der Zeichenfolge in eine Tabellenzelle mit Bootstrap zeigen. Es enthält einige Zeilenumbrüche \r\n. Ich habe versucht, style="white-space:pre" als this stackoverflow post schlägt vor, aber das bootstrap text wrap bricht. Ich habe auch versucht, \r\n zu <br> zu ändern, aber es funktioniert nicht. <br> zeigt sich als Text. DieseMehrzeiliger Text in einer Tabellenzelle mit Bootstrap

ist, wie mein Tisch sieht aus wie ..

<table id="table1" class="table table-bordered"> 
    <tbody> 
     <tr> 
      <th class="col-md-2" scope="row">Description</th> 
      <td id="description">Very long test with \r\n so I want to show this in multiline and also want to wrap the text using bootstrap.</td> 
     </tr> 
    </tbody> 
</table> 

Antwort

2

die Seitenumbrüche zu HTML Pausen (br-Tag) Ändern arbeitet in jsfiddle in Ordnung. Siehe meinen Link unten. Stellen Sie sicher, dass beim Generieren des HTML-Codes < und> Symbole generiert werden und nicht die HTML-Codes.

https://jsfiddle.net/joedonahue/zpj94p0b/

<table id="table1" class="table table-bordered"> 
    <tbody> 
     <tr> 
      <th class="col-md-2" scope="row">Description</th> 
      <td id="description">Very long test with <br/> so I want to show this in multiline and also want to wrap the text using bootstrap.</td> 
     </tr> 
    </tbody> 
</table> 
+0

hmmmm ja sind Sie hier richtig. Basierend auf Ihrem Feedback fand ich heraus, dass mein Problem dieser jquery Code '$ ('# description') war. Text ('this \ n has \ n newlines);' Meine Lösung hier, http://stackoverflow.com/questions/4535888/jquery-text-and-newlines Danke! –

Verwandte Themen