I am writing a script form confirmation and would like to confirm the correctness of this field with its onblur event. I would also like to use the bubbling event, so I donβt need to apply the onblur event to each individual field of the form. Unfortunately, the onblur event does not bubble. Just wondering if anyone knows about an elegant solution that can give the same effect.
ppk has a technique for this, including the necessary workarounds for IE: http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
( ) , , focusout IE:
focusout
if (myForm.addEventListener) { // Standards browsers can use event Capturing. NOTE: capturing // is triggered by virtue of setting the last parameter to true myForm.addEventListener('blur', validationFunction, true); } else { // IE can use its proprietary focusout event, which // bubbles in the way you wish blur to: myForm.onfocusout = validationFunction; } // And of course detect the element that blurred in your handler: function validationFunction(e) { var target = e ? e.target : window.event.srcElement; // ... }
. http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
' , Bubble .thanks.
onblur, addEventListener() useCapture false. :
onblur
yourFormInput.addEventListener('blur', yourFunction, false);
Firefox 51 onfocusout. onfocusout onblur.
onfocusout
aa, onblur ,
Source: https://habr.com/ru/post/1719387/More articles:What are the <%%> constructs called in asp.net? - .netms-access localization and boolean defaults - ms-accesswhy not use a Java start instead of other RIA frameworks? - javaDecryption using AES and CryptoAPI? When do you know KEY / SALT - c ++Objective-C: high level language? - objective-cKills the work of Oracle. 10 g - oracle3-tier web architecture: are layers profitable on separate machines? - coding-styleReplace MergeFields in a Word 2003 document and keep the style - c #jQuery getting the last index of an input field - jqueryFinding errors after moving SVN files - svnAll Articles