$(document).bind('click', function(e) {
var e = e || window.event; //浏览器兼容性
var elem = e.target || e.srcElement;
while (elem) { //循环判断至跟节点,防止点击的是div子元素
if (elem.id && elem.id == 'search') {
return;
}
elem = elem.parentNode;
}
$('.search-tip').addClass("hide"); //点击的不是div或其子元素
});