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: