<!DOCTYPE HTML>
<html>
<head>
<title>Esempio</title>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-latest.min.jsx"></script>
<script src="../js/jQuery/jQuery_v1.7.2.js" type="text/javascript"></script>
<style type="text/css">
#output{border:1px solid green}
</style>
<script type="text/javascript">
$(function(){
$("#input").bind("keyup", function(event, ui) {
$("#output").html(this.value.replace(/\n/g,"<br/>"));
});
$("body").on('click', '#output', function() {
var testo = $(this).text();
testo = testo.replace("<br/>",/\n/g)
$("textarea#input").val("");
alert(testo);
$("textarea#input").val(testo);
});
})
</script>
</head>
<body>
<textarea id="input"></textarea>
<p id="output"></p>
</body>
</html>