Проверьте целевой событие jquery снаружи
$(document).on("click", function (event) {
// If the target is not the container or a child of the container, then process
// the click event for outside of the container.
if ($(event.target).closest("#container").length === 0) {
console.log("You clicked outside of the container element");
}
});
patrick204nqh