I know this is an old question, but I searched a lot. I want to delete a class after clicking outside the body. here is my code:
Html
<div id="user-login-top">Enter</div> <div id="user-login-wrapper" class="">visible</div>
JQuery
$(function () { $("#user-login-top").on("click", function () { $("#user-login-wrapper").addClass("wide"); }); $(document).on("click", function (e) { if ($(e.target).is("#user-login-wrapper") === false) { $("#user-login-wrapper").removeClass("wide"); } }); });
and here is the fiddle: Fiddle
Appreciate your help! thanks
user3856699
source share