Div loses focus event realizes thinking _javascript skill

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.