que tienen un área de texto con id es #infoartist seguimiento:
<textarea id="infoartist" ng-show="dForm" style="width: 100%;" placeholder="Tell your contacts and collectors about yourself."></textarea>
En el código Javascript, voy a conseguir valor del área de texto y vuelva a colocar nueva línea de escape (n \ \ r) por <br />
etiqueta, tales como:
var text = document.getElementById("infoartist").value;
text = text.replace(/\r?\n/g, '<br />');
Así que si usted está usando jQuery (como yo):
var text = $("#infoartist").val();
text = text.replace(/\r?\n/g, '<br />');
Espero que te haya ayudado. :-)
Esto también funciona para mí. En jQuery puedes hacer algo como esto: $ ('# caption'). Html ($ ('# caption'). Text(). Replace (/ \ n \ r?/G, '
')); – DavGarcia
El salto de línea Regexp debe ser '/ (\ r \ n | \ n | \ r)/gm' http://www.textfixer.com/tutorials/javascript-line-breaks.php – tothemario
Si está utilizando jQuery Sugiero usar '.val' - http://stackoverflow.com/questions/5583040/show-newlines-in-html-textarea/5583094#5583094 –