JavaScript: Textarea words in the statistics text box to enhance user experience _ javascript skills

Source: Internet
Author: User
The popular micro-blog websites such as Twitter have a good user experience. When you enter text in the text box, the entered characters are automatically counted, and display the characters that can be entered by the user. In a micro-blog with a limit of 140 characters, such tips can greatly enhance the user experience, this article also tries to implement the popular micro-blog websites such as Twitter, with a good user experience, that is, when entering text in the text box, the input characters will be automatically counted, and display the characters that can be entered by the user. In a microblog with a limit of 140 characters, such tips can greatly enhance the user experience.

If this technology is implemented, I did some research and found that the implementation is actually quite simple. After a few lines of code, I can complete the input character statistics function. After actual tests, its text statistics are exactly the same as those of Weibo posts such as Twitter.

You can add a span to display the remaining words. Then, add an onkeydown and onkeyup event to Textarea and call another JavaScript function, the function call parameters are the span id and textarea id, and the remaining words are returned using innerHTML in JavaScript.

The following are the related JavaScript code::
Reference content is as follows:

The Code is as follows:


Related Article

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.