Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<html><head>
<title>Banana</title>
<script>
function countLines()
{
var area = document.getElementById("texta")
var text = area.value.replace(/\s+$/g,"")
var split = text.split("\n");
var temptext = [];
for (var i = 0; i < split.length; i++ ){
temptext = temptext + ((i+1)+'. '+split[i]) + '\n';
console.log(temptext);
}
area.value = temptext;
}
</script>
</head>
<body>
<textarea id="texta" cols="30" rows="8">
I think you could use the split function to break
the text into an array.
Then check the array's length to get
the line count.
</textarea>
<br>
<button onclick="countLines()">count</button>
</body></html>
Не.hpstuff каза:Така устроива ли те.
Код:<html><head> <title>Banana</title> <script> function countLines() { var area = document.getElementById("texta") var text = area.value.replace(/\s+$/g,"") var split = text.split("\n"); var temptext = []; for (var i = 0; i < split.length; i++ ){ temptext = temptext + ((i+1)+'. '+split[i]) + '\n'; console.log(temptext); } area.value = temptext; } </script> </head> <body> <textarea id="texta" cols="30" rows="8"> I think you could use the split function to break the text into an array. Then check the array's length to get the line count. </textarea> <br> <button onclick="countLines()">count</button> </body></html>
Е ,добре ,с канвас ,не ми пречи.hpstuff каза:Ти поглеждал ли си го изобщо там не се прави с никаква textarea а сичко се рисува с canvas.