How do I grab the value from an html form input box as its being entered?

后端 未结 3 1443
-上瘾入骨i
-上瘾入骨i 2020-12-21 14:09

How do I grab the value from an input box as its being entered?

3条回答
  •  温柔的废话
    2020-12-21 14:57

    I noticed you used the "jquery" tag. For jQuery, you can use the .keypress() method.

    From the API documentation:

    Description: Bind an event handler to the "keypress" JavaScript event, or trigger that event on an element.

    The event will fire every time keyboard input is registered by the browser.

    .keydown() and .keyup() are also available. Their behavior is slightly different from .keypress() and is outlined by the API documentation as well.

    The nice thing about jQuery is that you can use the same code across Firefox, IE, Safari, Opera and Chrome.

提交回复
热议问题