


jquery implements the method of hiding the drop-down div and mask layer when clicking on other areas_jquery
May 16, 2016 pm 03:24 PMThe example in this article describes how jquery implements hiding the drop-down div and mask layer when clicking on other areas. Share it with everyone for your reference, the details are as follows:
For a better user experience, when doing a drop-down to obtain other pop-up layers, when expanding the drop-down, click on other areas to automatically hide the collapse drop-down and mask layers. This effect uses a piece of js That's it.
The following picture is an example of a drop-down menu for reference:
Effect implementation source code:
$(document).bind('click', function(e) { var e = e || window.event; //浏览器兼容性 var elem = e.target || e.srcElement; while (elem) { //循环判断至跟节点,防止点击的是div子元素 if (elem.id && elem.id == 'menu') { return; } elem = elem.parentNode; } //点击的不是div或其子元素 $('.menuList,.overlay').hide(); });
I hope this article will be helpful to everyone in jQuery programming.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to hide WeChat friends without blocking or deleting them? How to hide WeChat friends without blocking or deleting them

How to hide works in Douyin short videos How to hide personal video works

How to hide Smart Island on Xiaomi Mi 14?

Detailed tutorial on hiding works on Douyin

How to deeply clean the hidden junk on your phone (completely remove junk from your phone's memory)

How to use PUT request method in jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

How to hide your own updates in Xianyu_Introduction to the method of closing updates in Xianyu
