I want to grab what a user is typing and display in a span above the textarea. But how do I grab the enter/return key (keyCode 13), and insert it correctly into the span so that a line break in the textarea, is a line break (
) in the span.
$('#InviteMessage').keyup(function(event)
{
var enter = "";
//if(event.keyCode = '13')
//enter = 'br />';
var text = $(this).val() + enter;
//replace all the less than/greater than characters
if(text == '')
$('#message').html('[Your personal message]');
else
$('#message').html(text);
}
);
The #InputMessage is the textarea and #message is the span above it.
You could simply do…
Or use
white-space: preon thespan, in which case thespanshould probably be adiv.