The .val() property of an item in jQuery for a doesn\'t seem to work with new lines. I need this function as the text-area is mean
In the case that
you are NOT displaying the .val() of the textarea in another page (for example, submit form to Servlet and forward to another JSP).
using the .val() of the textarea as part of a URL encoding (e.g. a mailto: with body as textarea contents) within Javascript/JQuery
then, you need to URLEncode the textarea description as follows :
var mailText = $('#mailbody').val().replace(/(\r\n|\n|\r)/gm, '%0D%0A');