问题
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