Z1X1C1 2017-01-09 13:05 采纳率: 50%
浏览 2373
已采纳

ie浏览器加载jquery,通过append()方法,事件没反应。

 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>
  • 写回答

2条回答

  • Go 旅城通票 2017-01-09 13:27
    关注

    设置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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类