is there a way to implement a text change event to detect text change on an HTML input text field?
It's possible to simulate these using key events (key press etc), however, it's really not performant and difficult, is there a better way?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- Carriage Return (ASCII chr 13) is missing from tex
- void before promise syntax
onChange doesn't fire until you lose focus later. If you want to be really strict with instantaneous changes of all sorts, use:
Well unless I misunderstand you can just use the
onChange
attribute:Note: in FF 3 (at least) this is not called until some the user has confirmed they are changed either by clicking away from the element, clicking enter, or other.
When I'm doing something like this I use the onKeyUp event.
but if you don't want to use an HTML event you could try to use jQuerys .change() method
in this example, the input would have to have a class "target"
if you're going to have multiple text boxes that you want to have done the same thing when their text is changed and you need their data then you could do this:
that way you can use the same code, for multiple text boxes using the same class without having to rewrite any code.