How to get text of an input text box during onKeyPress?

前端 未结 12 1648
遥遥无期
遥遥无期 2020-11-28 05:12

I am trying to get the text in a text box as the user types in it (jsfiddle playground):

12条回答
  •  伪装坚强ぢ
    2020-11-28 06:03

    Keep it simple. Use both onKeyPress() and onKeyUp():

    
    

    This takes care of getting the most updated string value (after key up) and also updates if the user holds down a key.

    jsfiddle: http://jsfiddle.net/VDd6C/8/

提交回复
热议问题