停止在hoverjQuery上更改偏移量
我想在浏览器窗口的左侧创建一个小条,它跟踪鼠标的Y位置并跟随鼠标。 到目前为止,没有问题。
但是现在我想在鼠标hover在div上时阻止div偏移,以便也可以点击div刚刚显示的内容。
我做了一个小提琴,让自己清楚
http://jsfiddle.net/UXWp6/
$(document).bind('mousemove', function(e){ $('#blokje').offset({top: e.pageY-100}); }); #blokje{width:200px; height:200px; background:white; position:relative; left:-180px; color:black; } #blokje:hover{left:0;} #blokje #tit{position:absolute; width:30px; height:200px; background:black; right:0; top:0; }   A link
This is the content where I would like to have my content clickable like that link on top
而不是一遍又一遍地实际绑定和解除事件。 我可能只是停止传播,所以文档永远不会发生。
$(function(){ $(document).bind('mousemove', function(e){ $('#blokje').offset({top: e.pageY-100}); }); $('#blokje').bind('mousemove', function(e){ e.stopPropagation(); }); });
提琴手