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
.val()
I have found a more convenient method using jquery.
samplecode
HTML
Encode
JS
$('button').click(function() { var encoded = $('').text($('textarea').val()).html();//the label element can be replaced by any element like div, span or else $('div').html(encoded.replace(/\n/g,'')) });