Javascript/jquery Function to detect mousemovement

Posted on 2013-11-08
Last Modified: 2013-11-28

I want to create a function that captures mouse movement over an object.
The idea is for part of a game whereby the user has to move the mouse up and down a certain number of times. So I need to tally this up so that I know when the user has completed.

Any ideas? And also best for performance
Question by:coolispaul
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 53

Assisted Solution

COBOLdinosaur earned 250 total points
ID: 39634938
just use the mouse over and increment a counter:


You will need to define cnt globally in your scripting.


Accepted Solution

Sar1973 earned 250 total points
ID: 39635764
You could use the onmousemove event, assigning it to the whole body of your page (see

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
REST call Failing 1 41
GitHub 1 40
How does GeoJson relates to Leaflet and Mapbox? 4 50
Submitting form with no refresh at the end 2 32
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question