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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

636 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