I have following small script to preview some text before submitting it to store in a database:
jQuery(function($) {
var input = $('#contents'),
preview = $('#previewaccordion div.viewcontents');
input.keyup(function(e) {
preview.html(input.val());
});
});
but if I type text with line-breaks it ignores them and writes all of them in one line. How could I replace the line-breaks so that they show correctly?