Jquery, how: click anywhere outside of the div, the div fades out

前端 未结 6 1433
甜味超标
甜味超标 2020-12-09 06:37

In Jquery how would i make it so that if i had a div, with different elements inside of it, a select, a search input, etc, that when i click outside of the div, on the page,

6条回答
  •  旧时难觅i
    2020-12-09 06:52

    Check this out
    Demo is here

    $('#menuBtn').click(function(e) {
        e.stopPropagation();
        $('.navMenuSecWrapper').fadeToggle();
        return false;
    });
    
    $(document).click(function() {
        $('.navMenuSecWrapper').fadeOut();
    });
    

提交回复
热议问题