user2344095
user2344095

Reputation:

jquery mousemove event with iframe

Mousemove event stops working when the cursor enters on iframe: example

$(document)
  .on('mousemove', function(event) {
     console.log(event)
  })

is it possible to follow the cursor when it is on iframe area?

Upvotes: 1

Views: 1149

Answers (2)

gaetanoM
gaetanoM

Reputation: 42054

You may use:

$(window).on('mousemove', function (event) {
    console.log( event.target.tagName + ': ' + event.type);
});

or:

$(function () {
    $(document).on('mousemove', function (event) {
        console.log( event.target.tagName + ': ' + event.type);
    });
});

Your problem in: $(document).on('mousemove', function (event) { is:

the event is executed before the dom is ready or the window is loaded.

Upvotes: 0

user2344095
user2344095

Reputation:

Found solution, add css attribute:

pointer-events: none;

example

Upvotes: 2

Related Questions