For example, to implement a click-list pop-up filter, click anywhere else to turn off the filter,
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/996160/201705/996160-20170517182726322-2007648649. PNG "style=" border:0px; "/>
The Filter class name
$ (document). Click (function () { $ (". submenu"). Hide ();}); $ (". submenu"). On ("click", function (Event) { //Cancel event bubbling var e = arguments.callee.caller.arguments[0] | | event; //If this sentence is omitted, the following e is changed to Event,ie run can, but other browsers are incompatible if (e && e.stoppropagation) { // this code is for mozilla and opera e.stoppropagation (); } else if ( window.event) { // this code is for ie window.event.cancelbubble = true; }});
You can successfully implement the requirement by first clicking anywhere in the document to hide the element and then binding the click event to the element to prevent bubbling to that element.
Click anywhere except the element to hide the element js