Jquery: how to hide the drop-down div and mask layer when clicking other regions _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces jquery's method of hiding the drop-down div and mask layer when clicking other areas, and involves jQuery's function of responding to mouse events to dynamically change the page element style, for more information about how to hide the drop-down p and mask layers when you click other areas in jquery, see the examples in this article. We will share this with you for your reference. The details are as follows:

For better user experience, when you pull down to obtain other pop-up layers, When you expand the drop-down, you need to click other areas to automatically hide the drop-down and mask layers, this effect can be achieved using a piece of js.

For example, a drop-down menu is for reference:

Result implementation source code:

$ (Document ). bind ('click', function (e) {var e = e | window. event; // browser compatibility var elem = e.tar get | e. srcElement; while (elem) {// cyclically judge to the following node to prevent clicking the p subelement if (elem. id & elem. id = 'menu ') {return;} elem = elem. parentNode;} // click not p or its child element $ ('. menuList ,. overlay '). hide ();});

I hope this article will help you with jQuery programming.

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.