There is a pop-up form, you need to close it if click outside of it and close-open if click on the button that calls it. Actually the code is written. But I can not understand how to combine in the selector $ (document) and $ (". Region-item"). Or maybe someone has a better snippet?
$(document).click(function (event) { if($(event.target).has(".all-regions").length == 1) { $(".all-regions").toggle(0).find(".search-region_row").focus(); } }); $(".region_item").click(function(event) { $(".all-regions").toggle(0).find(".search-region_row").focus(); });