开发者

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

开发者 https://www.devze.com 2023-03-19 06:16 出处:网络
My j开发者_C百科Query code: $(\'.box_class\').bind(\'mouseover\', function(e){ $(\'.tooltip\').css({\'top\':e.pageY,\'left\':e.pageX, \'z-index\':\'1\'});

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

精彩评论

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