模糊事件不会在IE7和IE6中被触发
我有一个下拉菜单,单击div中的一个,显示List。
I have a dropdown Menu where in a div is clicked and List is shown.
关注焦点我应该隐藏列表(即当用户点击或关注某些其他元素而不是鼠标移出时)。因此,我明显的选择是 onblur
。
On focus out I am supposed to hide the list(i.e. when the user clicks or focuses on some other element and not on mouse out). Hence my obvious choice was onblur
.
现在JavaScript似乎在Firefox中工作但在IE中不起作用因为我的div有一个指定高度和宽度的子div。这在测试文件中是可重现的。我正在使用jQuery。
Now the JavaScript seems to work in Firefox but not in IE thats because my div has a sub div with a height and width specified. This is reproducible in a test file. I am using jQuery.
这是Internet Explorer中的已知问题吗?什么是工作?
Is this a known issues in Internet Explorer? And what is the work around?
<html>
<head>
<title>Exploring IE</title>
<style type="text/css">
/** Exploring IE**/
.selected_option div {height:18px;}
</style>
<script type="text/javascript" src="jquery-1.3.2.min9919.js"></script>
<script type="text/javascript">
$().ready(function(){
$('.selected_option').blur(function(){
alert('blurred');
});
});
</script>
</head>
<body>
<div class="selected_option" tabindex="0">
<div>anywhere in the page</div>
</div>
</body>
</html>
IE专有重点突出
为我工作的事件:
The IE-proprietary focusout
event worked for me:
$('.selected_option').bind('focusout', function(){
alert('focusout');
});
同样,这是专有的(参见 quirksmode )但如果它可以解决您的问题,则可能是合适的。你总是可以绑定到 blur
和 focusout
事件。
Again, this is proprietary (see quirksmode) but may be appropriate if it solves your problem. You could always bind to both the blur
and focusout
events.