My question is almost like Automatic newline in textarea in textarea, but my context is more complicated. I have several text areas that have a 1 line attribute, which gives the impression of writing in the air (it simply means an empty place on a website without borders, since the textarea border that I set in css is like → border: 0;) .
I would like to use jQuery or Javascript to calculate when the text is entered by the user, if he has reached the end of the line of the text field, to automatically go to the next text field below. One way to solve this problem is to try to count the characters, but different characters have different widths.
I'm going to insert a hidden element at the edge of the text fields to act as a trigger for the nexttextarea.focus () event , but I don't know how I can achieve this.
I tried to figure it out and think of different hacks, but only one seems to be the solution ... Try to save each character in an array and give them a default space that takes a value in px ... for example 'a' => 0.7px, ' b '=> 0.9px or something like that if their list is somewhere (although it seems that from a memory point of view it would take a lot of overhead, as I would have to store both capital and small letters and many other characters .) Then do some calculations depending on the width of the browser if it has been resized or if not full size to determine when the width of the textarea line is filled with the edge of the browser width, (Currently the width of textarea is 100% and has no parent, therefore it fills the entire width of the browser).
If anyone has an idea for a complicated or easy way, I can do it, help me. The big problem is that IE and Mozilla introduce scrollbars if the browser window is resized and scrollbars are what I never want the user to see (remember how thin text is printed).
Forgive me for being so verbose. Just wanted to be accurate and detailed.
source
share