1 $(function(){ 2 $(document).bind("click",function(e){ 3 //id为menu的是菜单 4 if($(e.target).closest("#menu").length == 0 && $(e.target).closest("input").length == 0){ 5 //点击id为menu之外且id,则触发 6 hideMenu(); 7 } 8 }) 9 })