Saturday, 6 May 2017

Hide on body click


Hide div on body click or hide on anywhere click on body


jQuery(document).mouseup(function(e) {
    var $container = jQuery("id or class of container you want to hide");

    // if the target of the click isn't the container nor a descendant of the container
    if (!$container.is(e.target) && $container.has(e.target).length === 0) {
        $container.hide();
    }
});
banner
Previous Post
Next Post

0 comments: