What is the difference between onBlur and onChange attribute in HTML?

前端 未结 7 1516
[愿得一人]
[愿得一人] 2020-11-29 18:18

When is one called versus the other? Is there a situation were onChange would be called but onBlur would not be called?

7条回答
  •  余生分开走
    2020-11-29 18:45

    In Firefox the onchange fires only when you tab or else click outside the input field. The same is true of Onblur. The difference is that onblur will fire whether you changed anything in the field or not. It is possible that ENTER will fire one or both of these, but you wouldn't know that if you disable the ENTER in your forms to prevent unexpected submits.

提交回复
热议问题