开发者

How can I get my jQuery mouseover tooltip to follow the mouse pointer?

My j开发者_C百科Query code:

$('.box_class').bind('mouseover', function(e){
   $('.tooltip').css({'top':e.pageY,'left':e.pageX, 'z-index':'1'});
   $('.tooltip').fadeIn("fast");
}); 

It works fine, but I want that message would always follow the mouse pointer and now, when I "mouseover" on box_class it always stays at the same point. I probably should change mouseover function to another? Or how should I implement that?


Try mousemove:

$('.box_class').bind('mouseover', function(e){
   $('.tooltip').fadeIn("fast");
}); 

$('.box_class').bind('mousemove', function(e){
   $('.tooltip').css({'top':e.pageY,'left':e.pageX, 'z-index':'1'});
}); 

Keep your mouseout or mouseleave observer to close the tooltip.


Is the position set to absolute? If not try:

position:absolute;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜