requirement: click anywhere outside the pop-up box, and the pop-up box disappears
my code:
$(document).click(function (e) {
var _con = $("-sharpregister");
var _login=$("-sharplogin");
if (!_con.is(e.target) && _con.has(e.target).length === 0 || !_login.is(e.target) && _login.has(e.target).length === 0 ) {
$("-sharpregister").hide()
$("-sharplogin").hide()
}
})
result: the requirement can be fulfilled, but the click pop-up box itself and its input box will disappear. Solve