Let's say I have the string "Hello". This line obviously has five characters, but what is its length in pixels? Is there an easy way to determine this length in JavaScript? I thought of a solution where an additional user would need to be displayed to the user, but this method seems hacked and complicated.
In the enlarged image, I am trying to determine how many spaces would be needed to fill this line length. As you can probably say above, I think that the best option would be to simply measure the length of the string and one space from the user's point of view and calculate how many spaces the text based on this should replace. This will appear in the HTML input text, by the way.
Thanks.
source share