javascript - Span overflow when value set programmatically not typed -


i have created span on top of input field, manipulate styling of input text (fiddle).

it works great long don't type past input box border, or happens: enter image description here

now, learned have same scrolling effect input span, this:

    white-space: nowrap;     overflow: hidden; 

but, since not typing in span directly, updating innerhtml, has no effect.

is there way can update span, treat updates typing?

you can simulate same effect setting scrollleft high property on span type on it. need explicitly set same width on both input , span.

you can see working fiddle here.

i make "fake" span, hidden , variable width, can use set scrollleft property width text have if behave normally.

to handle "cursor moving" events, check cursor position (via @renatoprado), , set scrollleft percentage of width of text. it's working real input field, it's still not perfect. triggers on keyup (keydown not working well), has "lag". , can't see blinking cursor, that's annoying. sets on right track.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -