Identify a specific part of the screen

6

Is it possible for me to identify a specific part of the screen with jquery and javascript? For example when passing by height y does it perform for me a function? I imagine something like this:

var minha_altura = $(window).height();
var altura       = 400;
if(minha_altura > 400) 
{
   //faz algo
}

Is the concept correct and does it really work?

    
asked by anonymous 03.12.2015 / 12:23

1 answer

3

You can create an event in the window to detect the movement of the mouse and thus the pageX / Y of it.

window.addEventListener('mousemove', function(event) {
  if(event.pageY > 400) {
    //{...}
  } else {
    //{...}
  }
});

See an example:

window.addEventListener('mousemove', function(e) {
  document.body.innerHTML = '<p> PageY:'+e.pageY+'</p><p> PageX:'+e.pageX+'</p>';
});
    
03.12.2015 / 12:33