代码
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
window.onload = function(){
var txt = document.getElementById("txt");
var content = document.getElementById("content");
txt.onkeydown = function(ev){
var myEvent = ev||event;
if(myEvent.keyCode == 13){//回车
content.value += txt.value + "\n";
txt.value = "";
}
}
}
</script>
</head>
<body>
<input type="text" id="txt" placeholder="请输入">
<br/>
<br/>
<textarea id="content" cols="40" style="height: 200px;"></textarea>
</body>
</html>