Jquery and Hide a div on a click
问题 i have a little problem with JQuery. Well, i have a and i want to hide this div when an user click in a zone that is not in the like the "notifications" behavior in facebook. The solution that i found is to use jQuery.live() method but i think there is a better way to do it. Thank you. 回答1: Assuming: <div class="notification">You have 3 new messages</div> use: $(document).click(function(evt) { if ($(this).closest("div.notification").length == 0) { $("div.notification").fadeOut(); } });