Lucas Matos
Lucas Matos

Reputation: 1152

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

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.

Upvotes: 0

Views: 1120

Answers (2)

Timbadu
Timbadu

Reputation: 1551

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();
});

Upvotes: 1

Pethical
Pethical

Reputation: 1482

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.

Upvotes: 1

Related Questions