Event bubbling and the onblur event

后端 未结 5 1195
生来不讨喜
生来不讨喜 2021-01-05 23:24

I\'m writing a form validation script and would like to validate a given field when its onblur event fires. I would also like to use event bubbling so i don\'t have to attac

5条回答
  •  花落未央
    2021-01-06 00:29

    To use bubbling with onblur event, Then you can use addEventListener() and set the useCapture parameter to false. Like this:

    yourFormInput.addEventListener('blur', yourFunction, false);
    

    Firefox 51 and below do not support the onfocusout event. So don't use onfocusout instead of onblur event.

提交回复
热议问题