html <input type=“text” /> onchange event not working

后端 未结 12 2538
-上瘾入骨i
-上瘾入骨i 2020-11-30 01:13

I am trying to do some experiment. What I want to happen is that everytime the user types in something in the textbox, it will be displayed in a dialog box. I used the

12条回答
  •  臣服心动
    2020-11-30 01:42

    onchange only occurs when the change to the input element is committed by the user, most of the time this is when the element loses focus.

    if you want your function to fire everytime the element value changes you should use the oninput event - this is better than the key up/down events as the value can be changed with the user's mouse ie pasted in, or auto-fill etc

    Read more about the change event here

    Read more about the input event here

提交回复
热议问题