JQuery: Click the method to close the specified layer outside the specified region [classic], jquery Region

Source: Internet
Author: User

JQuery: Click the method to close the specified layer outside the specified region [classic], jquery Region

This example describes how to disable a specified layer by clicking jQuery outside a specified region. We will share this with you for your reference. The details are as follows:

Click outside the specified area on the page to close the layer. The common effect is to click outside the pop-up layer to close the pop-up layer. Today, we have encountered such an effect. It is quite simple to implement it with jQuery. By the way, I reviewed the relevant knowledge.

$ (Document ). mouseup (function (e) {if(((e.tar get ). parent ("# big_map "). length = 0) {$ ("# big_map "). hide ("fast ");}})

The jquery code above indicates that the function is triggered when the mouse button is released on the page. Locate the Element Set of the trigger event that contains the unique parent element of all matching elements, and determine the number of elements found. If it is equal to 0, the specified layer is disabled outside the specified region.

Definition and usage:

E.tar get: the element that triggers the Click Event (DOM object). It never changes and is the target DOM element that directly accepts the event.
Parent ([expr]): gets a set of elements that contain a unique parent element that matches all elements.
Length: the number of elements in the jQuery object.
Mouseup event:
A mouseup event occurs when the mouse button is relaxed on the element.
Unlike the click event, a mouseup event only requires a relax button. When the mouse pointer is over the element, the Relax button triggers this event.
The mouseup () method triggers the mouseup event, or specifies the function that runs when a mouseup event occurs.

Related Article

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.