A JavaScript code processes the characters in textarea into each line.

Source: Internet
Author: User

A JavaScript code processes the characters in textarea into each line.

<! Doctype html> 


How does JAVA read only the content of the last row of textarea?

If you press enter, you can use split ("\ n") to break down the string and then go to the last element in the array.

If it doesn't, it's hard to get the front-end js to get the length of the string in textarea to get cols rows. Use the string length to mod rows and then subString ??

I have a question: why do I go to the last line?

How to Implement javascript to display only 72 characters in one line, more than 72 characters in addition to one line

Here is 7. Change it to the number you want ~
<Html>
<Head>
<Title> </title>
</Head>
<Body>
<Div id = "hi"> when I go to school late in spring, I don't need to worry about it. When the wind falls into the dark red green leaves, the branches are full. </div>
<Script type = "text/javascript">
Var $ = function (ID) {return document. getElementById (ID );};
Var length = 7;
Var arr = [];
For (var I = 0; I <= $ ("hi"). innerText. length/7; I ++ ){
Arr. push ($ ("hi"). innerText. substring (I * length, (I + 1) * length ));
}
$ ("Hi"). innerHTML = arr. join ("<br/> ")
</Script>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.