<!doctypehtml>
<htmllang="en">
<head>
<metacharset="utf-8">
<title>每天一个JavaScript实例-处理textarea中的字符成每一行</title>
<script>
functionclicka(){
console.log("aaa");
varaa=document.getElementById("text");
varlines=aa.value.split("\n");
varbbb=document.getElementById("result");
varstring="";
for(i=0;i<lines.length;i++){
string+=lines[i]+"<br/>";////</br>和<br/>应该用<br/>
}
bbb.innerHTML=string
}
</script>
</head>
<body>
<textareaid="text"placeholder="请输入多行文字"></textarea>
<divid="result"></div>
<ahref="javascript:void(0);"onClick="clicka()">处理换行</a>
</body>
</html>