Look at this article to understand the following events (from the consortium).
Blur Event: Blur event occurs when the element loses focus.
Focused event: the focus () method is used to give the Text field focal point (also a value that gives some elements the focus event).
TabIndex Property: The TabIndex property can set or return the tab control order of the buttons.
We all know that Blur is only for form controls, and for spans, Div, Li, and so on, there's no way to trigger their actions, now we just need to set a TabIndex property to trigger their focus event.
Real Project Code:
Copy Code code as follows:
Esc.popupmenu.prototype._createpopup=function () {
var popupdiv = $ (' <div tabindex=1></div> '); Create Div
Popupdiv.appendto (this._owner.element); Add div to span
var _popup=popupdiv[0];
_popup.hide=function () {
Popupdiv.hide ();
},
_popup.show=function () {
Popupdiv.show ();
Popupdiv.focus (); <span style= "White-space:pre" > </span>//let Div get focus
};
Popupdiv.blur (function () {
Popupdiv.hide ();
});
return _popup;
}
This code means that I use DIV to simulate a createpopup (ie can be directly generated), give it a TabIndex attribute when generated, and then add span, then let IT support display hidden. It is particularly noteworthy that popupdiv,focus () must give the div a focus, otherwise it has no focus on how to lose focus.