I want to hide a div by clicking on the close link in it, or by clicking anywhere outside that div.
I am trying following code, it opens and close the div by clicking close link properly, but if I have problem to close it by clicking anywhere outside the div.
<div id="float_tabs">
<ul>
<li><a href="#sign_in"><?= Yii::t('app','Sign in'); ?></a></li>
<li>
<a href="#register"><?= Yii::t('app','Create an account'); ?></a>
<button type="button" class="close" aria-hidden="true" id="open" onclick="$('.floating_box').toggle('.hide_sign_in_box');">×</button>
<script src="jquery-1.12.0.min.js">
$(document).ready(function () {
$('#close').hide()
});
$('#open').on('click', function () {
$('#float_tabs').show(500)
});
$(document).mouseup(function (e) {
var popup = $("#float_tabs");
if (!$('#open').is(e.target) && !popup.is(e.target) && popup.has(e.target).length == 0) {
popup.hide(500);
}
});
</script>