Detecting input change in jQuery?

后端 未结 8 2135
Happy的楠姐
Happy的楠姐 2020-11-22 04:11

When using jquery .change on an input the event will only be fired when the input loses focus

In my case, I need to make a call to the serv

8条回答
  •  醉话见心
    2020-11-22 04:37

    If you've got HTML5:

    • oninput (fires only when a change actually happens, but does so immediately)

    Otherwise you need to check for all these events which might indicate a change to the input element's value:

    • onchange
    • onkeyup (not keydown or keypress as the input's value won't have the new keystroke in it yet)
    • onpaste (when supported)

    and maybe:

    • onmouseup (I'm not sure about this one)

提交回复
热议问题