Champion Champion - 3 months ago 7
jQuery Question

Capturing the Mouse Movement

I am a novice and just completed the basic of the Jquery from a book Castledine E. Sharkie C. - jQuery. Novice to Ninja 2nd Edition - 2012

Now I want to learn something significant but didn't know where to move.

You must have seen that there are websites such as Optinmonster.com that track Mouse Movement and captures. I think this is possible through some Jquery.

I searched a lot over the Internet and find this -
https://api.jquery.com/mousemove/

Please guide me am I heading in the right direction? Is it the Jquery function/method that captures mouse movement and records it.

Answer

Lot of samples available online. To start with refer : http://www.w3schools.com/jquery/jquery_ref_events.asp

<script>
$(document).ready(function(){
    $(document).mousemove(function(event){
        $("span").text(event.pageX + ", " + event.pageY);
    });
});
</script>