jQuery messes up line breaks
Clash Royale CLAN TAG #URR8PPP jQuery messes up line breaks I've got an if else statement. Switching between a text in <p> tag and the same text in an editable <textarea> <p> <textarea> The problem is that: you press the edit button and script converts p tag to textarea. Text is converted fine with line breaks. You press save. Text is converted correctly back into a p tag again. You try to press edit again... but this time, the linebreaks are ignored!? var curState = "Ret"; if (curState == "Gem"){ curState = "Ret"; var p = btn.closest("div").find("textarea"); var t = jQuery(this).closest("div").children("div").children('textarea').val().replace(/(rn|n)/g, "<br/>"); var ta = jQuery("<p/>", { "html": t }); p.replaceWith(ta); }else{ curState = "Gem"; var p = jQu...