简体   繁体   中英

How do you register an onclick event while having onmouseover using Javascript

I have a function that tracks the user's mouse to show them visually where they are on an x,y grid. When the user's mouse is over the image, a function is called via onmouseover="gridFunction();".

The problem is that I want to record the user's click ( onclick or onmousedown ) as they move around the grid image. So I'm trying to stack an onclick with an onmouseover .

Any suggestions? I tried creating document.onclick = "clickFunction();" but for some odd reason this never gets called when I click on the website (even when I'm not hovering over the image).

我建议使用jQuery 的 events api - 它非常易于使用,并且很可能能够处理您的情况。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM