最佳答案
Possible Duplicate:
jQuery convert line breaks to br (nl2br equivalent)
Currently I add <BR>
for each evt.which == 13
. Is there a nl2br()
for JavaScript, so I can do away with this evt.which == 13
?
How different is this from php.js
$('#TextArea').keypress(function(evt) {
if (evt.which == 13) {
var range = $('#TextArea').getSelection();
var image_selection = range.text;
$('#TextArea').replaceSelection('<BR>');
$('#TextArea1').html($('#TextArea').val());
}
});