I would like to select whole body besides one div. Or maybe someone has better idea how to accomplish my problem.
I want to on “cs-dropdown” click toggle, and then if someone clicks out of it anywhere in the body hide it. The problem is that “cs-dropdown” is inside the body right after I open it with “cs-dropdown” click I am closing it with body click. Thanks for any help.
$(".cs-dropdown").click(function () {
$(".customer-service-dd").toggle();
});
$("body").click(function () {
if($(".customer-service-dd").is(":visible") == true)
{
$(".customer-service-dd").toggle();
}
});
Use
stopPropagation()to stop the event from bubbling to the body: