In a portion of my code to get a "report view" where the element is different (textarea becomes a div or span) and use the same data with newlines I replace the new lines with page breaks.
Currently the function I use:
$.each($('[id^="mytext-text"]'),(i,e)=>{$(e).html($(e).html().replace(/\n/gm,'<br>'))})
I often find myself using this same format for replacing other things, i.e.,
$(e).text($(e).text+'more text');
Is there a better way (either about using line breaks or about the .text(.text())
? I've seen suggestions to simply write your own function butbut I feel like that doesn't solve the generalized problem.