var preserved = $('textarea').val().replace(/\n\r?/g, '%0D%0A');
jQuery Preserve textarea line breaks for AJAX call
By default, JavaScript will ignore textarea line breaks. This one-liner replaces them with their URL encoded values.
Snippet Viewed 15664 times.
Share your jQuery code snippets:
- Get some recognition & link back to your site.
Related Articles