Home > Web Front-end > JS Tutorial > javaScript example - processing characters in textarea into each line

javaScript example - processing characters in textarea into each line

高洛峰
Release: 2016-11-25 09:25:03
Original
1082 people have browsed it

<!doctype html>
<html>
<head>
   <meta charset="utf-8">
    <title>每天一个JavaScript实例-处理textarea中的字符成每一行</title>
    <script>
     
function clicka(){
console.log("aaa");
var aa = document.getElementById("text");
var lines = aa.value.split("\n");
var bbb = document.getElementById("result");
var string = "";
for(i=0;i<lines.length;i++){
string+= lines[i]+"<br />";////</br>  和<br /> 应该用 <br />
}
bbb.innerHTML=string
}

    </script>
   </head>

<body>
    <textarea id="text" placeholder="请输入多行文字"></textarea>
    <div id = "result"></div>
    <a href="http://www.php1.cn/">
Copy after login


Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template