I am creating a JavaScript code editor online, and right now I am counting the line on the left side of the editor. I can not understand how this can be made when a new line is created, this line adds a number to +1, so in this new line it will be the row number on the left. Does anyone know the best way to do this?
You can use each event to split into an array, then get the array count .
$ ('textarea') keyboard (function (if ($ (this) .val (). LastIndexOf ('\ n')! = - 1) X = $ (this ) .val () .partition ('\ n'); $ ('div'). Text (x.length); // this will be line number});
Bela < / H2>
Comments
Post a Comment