1 $(function(){ 2 $(document).bind("click",function(e){ 3 //id為menu的是菜單 4 if($(e.target).closest("#menu").length == 0 && $(e.target).closest("input").... ...
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 })