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

前端 未结 6 1432
甜味超标
甜味超标 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条回答
  •  青春惊慌失措
    2020-12-09 06:59

    You can bind a click handler on $(document) like

    $(document).click(function(){
      $(this).unbind('click');
      $('#menu').fadeOut();
      }
    

提交回复
热议问题