English 中文(简体)
如何防止在某一分子在 mo后发射烟??
原标题:How to prevent mouseleave from firing when an element is following the mouse?
  • 时间:2012-01-11 11:38:34
  •  标签:
  • jquery

The code below moves a div to the correct height upon mouseenter of another element (which I will refer to as container from now on), then as the mouse moves it adjusts the left position of the element so that it follows the mouse left and right.

Finally when the mouse leaves the container div, the element is hidden.

$( body ).on( mouseenter mouseleave mousemove ,  .seek-bar , function (e) {
    var $seeker = $( #seek-head );

    if (e.type ==  mouseenter ) {
        var top = Number($(this).offset().top);
        $seeker.css({ top: top +  px  }).show();
    }
    else if (e.type ==  mouseleave ) {
        $seeker.hide();
    }

    if (e.type ==  mousemove ) {
        var x = e.pageX;
        $seeker.css({ left: x +  px  });
    }
});

尽管这一工程是细微的,但由于改写在<条码>上(>查询人上)而不是集装箱元素而引发元素。 <代码>mouseleave 事件发生时,我不会wan。

我如何防止这种情况?

注:<代码> 申请者 部件直接载于<代码><and'gt;,因此永远放在集装箱内。

最佳回答

Rewrote you code a litte, but why don t you put the mouseleave on the element that is infront of the container element?

var $seeker = $( #seek-head );    
$( body ).on({
    mouseenter: function() {
        var top = Number($(this).offset().top);
        $seeker.css({ top: top +  px  }).show();
    },
    mousemove: function() {
        var x = e.pageX;
        $seeker.css({ left: x +  px  });
    }
},  .seek-bar );

$( body ).on( mouseleave , $seeker, function() {
    $seeker.hide();
});
问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签