$("#right").mouseenter(function () {});$("#right").mouseleave(function () {});
//我想在执行mouseenter的时候把mouseleave给禁用掉,因为在FF浏览器里 mouseenter和mouseleave几乎是同时执行的

解决方案 »

  1.   

    $("#right").mouseenter(function () {});$("#right").mouseleave(function () {return;});
    行不!
      

  2.   


    mouseenter 用 mouseover  事件代替, mouseleave 用 mouseout 或 blur 事件代替 看看可以不?
      

  3.   

    mouseenter 用 mouseover 事件代替, mouseleave 用 mouseout 或 blur 事件代替 看看可以不?还是不行,是一张图片blur 不行
      

  4.   


    鼠标离开的时候 还是需要触发mouseleave事件 
      

  5.   

    http://xiebiji.com/2010/02/js_mouseenter_mouseleave/?wptheme=Plainscape&ie=1可以试试这个方法
      

  6.   


    嗯 我在FF中测试 是这样的 IE8 和 chrome 都是没问题的
      

  7.   

    onclick="javascript :return false;"
      

  8.   


    <div id="book" style="width: 396px; height: 495px;">
            <div id="right" style="width: 398px;
                height: 494px; float: left; background: url(/images/1.jpg) no-repeat top left;
                cursor: pointer;">
            </div>
        </div>var i = 1;
        $("#right").mouseover(function (e) {
            alert(e.type);
            i++;
            if (i > 2) {
                i = 1;
                return;
            }
            var roll = $("<div/>", {
                css: { position: "absolute",
                    border: "solid 1px #999",
                    left: "398px",
                    top: "8px",
                    height: "494px",
                    width: "8px",
                    background: "#fff url(/images/eCX.png) repeat-y -200px 0px"
                }
            }).appendTo($("#book").parent());
            $(roll).animate({
                left: "10px",
                width: "398px",
                "background-position": "272px 0px"
            }, 1000, function () {
                $("#right").css({ "background": "url(/images/" + i + ".jpg)" });
                $(roll).fadeOut(300, function () {
                    $(roll).remove();
                })
            });
        });
        var j = 2;
        var a = 1;    $("#right").mouseleave(function (e) {
            alert(e.type);
            j--;
            if (j < 1) {
                j = 2;
                //return;
            }
            var roll = $("<div/>", {
                css: { position: "absolute",
                    border: "solid 1px #999",
                    left: "8px",
                    top: "8px",
                    height: "494px",
                    width: "8px",
                    background: "#fff url(/images/eCX.png) repeat-y 200px 0px"
                }
            }).appendTo($("#book").parent());
            $(roll).animate({
                left: "8px",
                width: "398px",
                "background-position": "272px 0px"
            }, 1000, function () {
                $("#right").css({ "background": "url(/images/" + j + ".jpg)" });
                $(roll).fadeOut(300, function () {
                    $(roll).remove();
                })
            });
        });
    // 可以在火狐中测试下效果,在images文件夹中有1.jpg,2.jpg  两张图片
      

  9.   

    简单得很$("#right").mouseenter(function () {$("#right").mouseleave=undefind;});
      

  10.   


    这样子的话 mouseenter事件就不执行了
      

  11.   

    event.PreventDefault()
      

  12.   


    $("#right").mouseenter(function (event) {event.PreventDefault();});
    这样子的话 mouseenter事件失效了  
      

  13.   

    event.PreventDefault()
    jquery中有这个函数的。
    1.4应该是有的。
      

  14.   

    应该是代码写的有问题,我写了一个简单的mouseenter和mouseleave时候是不会同时触发的,就是有翻数效果的时候 才会出现mouseenter和mouseleave几乎同时执行,谁能帮忙测试下  感激不尽刚换个工作第一个任务就是这个 ,有点折腾
      

  15.   


    <!DOCTYPE HTML> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <title>mouseerter与mouseover区别(IE下测试)</title> 
    </head> 
    <body> 
    <div id="result" style="position:absolute;right:100px;top:5px;width:250px;height:400px;border:2px solid gray;overflow:auto;"> 
    </div> 
    <h3>1,鼠标在div[id=parent1]内部移动时也会触发mouseover事件</h3> 
    <div id="parent1" style="width:400px;border:1px solid gray;padding:5px;"> 
    <div id="child11" style="width:100px;height:100px;background:gold;float:left;">Child11</div> 
    <div id="child12" style="width:100px;height:100px;background:gold;float:right;">Child12</div> 
    <div style="clear:both;"></div> 
    </div>  
    <h3>2,鼠标在div[id=parent2]内部移动时也不会触发mouseenter事件</h3> 
    <div id="parent2" style="width:400px;border:1px solid gray;padding:5px;"> 
    <div id="child21" style="width:100px;height:100px;background:gold;float:left;">Child21</div> 
    <div id="child22" style="width:100px;height:100px;background:gold;float:right;">Child22</div> 
    <div style="clear:both;"></div> 
    </div> <script type="text/javascript"> 
    function on(el,type,fn){ 
    el.addEventListener ? el.addEventListener(type, fn, false) : el.attachEvent('on' + type, fn); 

    function $(id){ 
    return document.getElementById(id); 

    var p1 = $('parent1'), 
    p2 = $('parent2'); 
    function fn(e){ 
    var d = document.createElement('div'); 
    d.innerHTML = e.type; 
    $('result').appendChild(d); 

    on(p1,'mouseover',fn); 
    on(p2,'mouseenter',fn); 
    </script> 
    <body> 
    </html>