SyntaxFix
Write A Post
Hire A Developer
Questions
Here is an idea as you may have multiple newline in a textbox:
var text=document.getElementById('post-text').value.split('\n'); var html = text.join('<br />');
This HTML value will preserve newline. Hope this helps.