Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:13:03+00:00 2026-06-10T20:13:03+00:00

Suppose we have a <div> with a mousemove handler bound to it. If the

  • 0

Suppose we have a <div> with a mousemove handler bound to it. If the mouse pointer enters and moves around this div, the event is triggered.

However, I am dealing with a rich web application where <div>s move around the screen, appear and disappear… So it may happen that a <div> appears under the mouse pointer. In this case, mousemove is not triggered. However, I need it to be. (Note that replacing mousemove with mouseover does not change this behavior.)

Specifically, the <div> has to be highlighted and I deem it as a UI flaw to require the user to do a slight mouse move in order to trigger the highlighting.

Is it possible to trigger the mousemove event programatically? And I do not mean

document.getElementById('mydiv').onmousemove();

because onmousemove is parametrised by the event object, which I do not have.

Is it possible to make browser behave as if onmousemove was triggered on the current mouse’s position (although in fact the mouse didn’t move)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:13:05+00:00Added an answer on June 10, 2026 at 8:13 pm

    You actually can create a mousemove event object to pass in, using something like this:

    window.onload = function () {
        document.getElementById("test").onmousemove = function(e) { console.log(e); };
        document.getElementById("test").onclick = function(e) { 
            var e = document.createEvent('MouseEvents'); 
            e.initMouseEvent('mousemove',true,true,document.defaultView,<detail>,<screenX>,<screenY>,<mouseX>,<mouseY>,false,false,false,false,<button>,null);
            this.onmousemove(e); 
        };
    };
    

    Of course, here I’m firing it on a click, but you can do it on whatever event you want, such as when your div becomes visible, check to see if the mouse is within it. You just need to make sure your parameters are right, and you need to track the mouse position on your own. Also, there’s some differences in IE, I think. Here’s my source: http://chamnapchhorn.blogspot.com/2008/06/artificial-mouse-events-in-javascript.html. He added a little extra code to account for it.

    Here’s a fiddle to play around with. http://jsfiddle.net/grimertop90/LxT7V/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have an div. Inside this div, I have two divs floating left,
Suppose I have this html markup: <div id=wrapper> <pre class=highlight> $(function(){ // hide all
Suppose i have this structure of elements: <div class=parent> <div class=something1> <div class=something2> <div
Suppose I have the following html: This a test of <code>some code</code>. <div class='highlight'>
A newbie question,really. Suppose I have a html table like this: <div id=div1> <table
I have this jquery script which suppose to hide/show div element base on the
Suppose I have an element like this: <div id=dv class=red green blue>Something Here !!</div>
Suppose I have an HTML snippet like this: <div> Hello <strong>There</strong> <div>I think <em>I
suppose I have a html markup like this: <div> <p> this is the parent
Suppose I have this: <div id=apple class=fruit></div> <div id=orange class=fruit></div> <div id=grape class=fruit></div> <div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.