This article mainly introduces the use of javascript Delegate blur and focus. The example analyzes the usage of javascript Delegate and the usage skills for common browsers, for more information about how to use the javascript Delegate blur and focus, see the example in this article. Share it with you for your reference. The specific analysis is as follows:
Opera (9.5b) cannot correctly trigger all focus and blur events twice;
Therefore, the focus and blur event processing functions can be delegated to the event capture phase.
Example 1 (List class ):
The Code is as follows:
- List item 1
- List item 1.1
- List item 1.2
- List item 1.3
Other list items
Example 2 (Form class ):
The Code is as follows:
Here we listen to the ol block on the outermost layer. If we use the blur and focus events, we only target the entire ol block, so how to deal with the focus and blur events of the controls in it?
The processing method is as follows:
IE processing:
The Code is as follows:
$ ('LIST'). onmouseover = handleMouseOver;
$ ('LIST'). onmouseout = handleMouseOut;
$ ('LIST'). onfocusin = handleMouseOver;
$ ('LIST'). onfocusout = handleMouseOut;
You can also write it in the following format:
The Code is as follows:
$ ('LIST'). attachEvent ('onfocusout', handleMouseOut, true );
If you want to pass parameters, you can add an intermediate function, such
The Code is as follows:
$ ('LIST'). attachEvent ('onfocusout', function (event, myparams) {handleMouseOut (event, myparams);}, true );
FF processing:
The Code is as follows:
$ ('LIST'). addEventListener ('core', handleMouseOver, true );
$ ('LIST'). addEventListener ('blur', handleMouseOut, true );
I hope this article will help you design javascript programs.