How to hide an iframe (that is following the mouse) when it passes over a link?

怎甘沉沦 提交于 2020-01-14 05:24:04

问题


I have an iframe binded to mousemove.

That means this iframe follows the mouse cursor everywhere it goes.

But i need to hide/disable/make it invisible when it passes over a link.

I need to hide/disable the iframe when passing over a link otherwise the link become unclickable (since the iframe is over it).

It have to be general links, so i cant use an id, it must be related to general link tag


THE ANSWER: http://jsfiddle.net/ZPA5g/

I will hide the form in links, inputs, and images or whatever elements i need.

Read the comments on both answers to check its differences. Both works.


回答1:


Could this be fixed by using the .on() function?

http://api.jquery.com/on/

OK.

$('a').live("hover", function() {
  $('#tail').hide();
});

or.

$('a').live("mouseenter", function() {
  $('#tail').hide();
});
$('a').live("mouseout", function() {
  $('#tail').show();
});



回答2:


Your code:

$(document).bind('mousemove', function(e){
$('#tail').css({
   left:  e.pageX - 20,
   top:   e.pageY - 18
});
});

Try this:

$(document).bind('mousemove', function(e){
$('#tail').css({
   left:  e.pageX - 20,
   top:   e.pageY - 20
});
});

+2px space over the cursor is enough.



来源:https://stackoverflow.com/questions/10840226/how-to-hide-an-iframe-that-is-following-the-mouse-when-it-passes-over-a-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!