0
我没有使用“.is”工作。它在IE9,Firefox和其他现代浏览器的工作很好,但不是IE8或IE7如何让“.is”在旧版Internet Explorer中工作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
$('body').click(function() {
if (!$('.myDiv').is(":hover")) {
alert("outside of blue div");
}
});
</script>
<div class="myDiv" style="width:150px; height:150px; background:blue"> </div>
</body>
</html>
或者看看这里http://jsfiddle.net/uh8RB/
我如何得到它在IE8和更早的版本?
谢谢,但问题是,报警触发,如果我的东西克利克的div内即可。下面是一个例子(尝试点击文本):http://jsfiddle.net/uh8RB/12/ – WIRN
@ user263091:更改'if(!$(e.target).is('。myDiv')){'to 'if($(e.target).closest('。myDiv')。length === 0){'http://jsfiddle.net/uh8RB/14/ –