When you enter text in the text box, the system automatically counts the entered characters and displays the characters that can be entered by the user. In fact, JavaScript can also be used, the following is an example of a good user experience for popular Weibo websites such as Twitter, the system automatically counts the entered characters and displays the characters that the user can enter. In a micro-blog with a limit of 140 characters, such tips can greatly improve 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.
Core Javascript code:
The Code is as follows: