@,
Insert title here
function isParent (obj,parentObj){
while (obj != undefined && obj != null && obj.tagName && obj.tagName.toUpperCase() != ‘BODY’)
{
if (obj == parentObj)
{
return true;
}
obj = obj.parentNode;
}
return false;
}
//判断点击对象的 父亲是不是$(“.floatLayer”)[0]
$(function(){
$(document).click(function(event){
if(!isParent(event.target, $(“.floatLayer”)[0]))
{
$(“.floatLayer”).hide();
}
});
});
如果拿掉 while中 拿掉obj.tagName
则在ie7和 火狐下 都有问题
maml7年前 (2011-09-07)回复