This example describes the way JS adds line numbers to a textarea text box. Share to everyone for your reference. Specifically as follows:
Here using the JS implementation let textarea text box display line number function, each line is preceded by a number of numbers, if used to display code, you can directly find a line, if you do not show line number, but also to do their own work to check, want this function, you just set a good textarea ID, and add code in the JavaScript code part, the text box is a long width is controlled by the CSS, you can try to modify, the long width of the display to match JS.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-textarea-show-row-num-codes/
The specific code is as follows:
The
wants this article to help you with your JavaScript programming.