1 /** 2 * 点击隐藏(失去焦点后,点击元素以外区域后,元素隐藏) 3 * @constructor 4 * @author putaoshu@126.com 5 * @date 2012-02-08 6 * @param {Object} obj 主对象 7 * @example 8 vui.clickhide($('#test')) 9 vui.clickHide($('#test')) 10 */ 11 12 vui.clickhide = vui.clickHide = function(obj){ 13 var $this = $(obj); 14 var mouseInsideTag = false; 15 16 $this.show(); 17 18 $this.hover(function(){ 19 mouseInsideTag=true; 20 }, function(){ 21 mouseInsideTag=false; 22 }); 23 24 $("html,body").mouseup(function(){ 25 if(!mouseInsideTag) $this.hide(); 26 }); 27 } 28 29