ie浏览器加载jquery,通过append()方法,使光标轻过当前元素时显示最上端,可是按123456按钮却没反应,连续按两下才有反应。像firefox、chrome等浏览器都能正常显示,惟有IE8、9、10、11统统都是一样的,点一下没反应,点两下才有反应了。
代码如下:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.js"></script>
</head>
<body style="position: relative;">
<div id="main">
<div class="editor" style="position: absolute;height:500px;width:600px;background-color:lime;">aaaaaaaaa</div>
<div class="editor" style="position: absolute;height:500px;width:600px;left:300px;background-color: aqua;">bbbbbbbb
<button onclick="alert('ok')">123456</button>
</div>
</div>
</body>
</html>
<script>
$("#main").delegate(".editor","mouseover",function(e){
$("#main").append($(this))
})
</script>
设置z-index就行了,dom操作导致ie重复触发mouseover
$("#main").delegate(".editor", "mouseover", function (e) {
$("#main").append($(this))
console.log(new Date().getTime())//加这个你 就知道了,不停的在操作
})
===》
<script>
var zIndex = 1;
$("#main .editor").mouseenter(function (e) {
$(this).css('z-index',zIndex++)
console.log(new Date().getTime())
})
</script>
先换个浏览器试试了