Wednesday 27 March 2019

How to hide a DIV when the user clicks outside of it

<script>
jQuery(document).on('click', function (e) {
    if (jQuery(e.target).closest(".sle1").length === 0 && jQuery(e.target).closest(".city-filter").length === 0) {
        jQuery(".city-filter").slideUp();
        jQuery(".sle1").removeClass("active");
    }
});
</script>

No comments:

Post a Comment