javascript - without jquery i need to find out if the mouse is over an element, not determine when it becomes over (in case it doesn't move to trigger onmouseover) -


without jquery

basically looking ability see if mouse on div when countdown finishes

if user on div perform action div

onmouseover triggers when mouse crosses threshold of div, if mouse hasn't moved wouldn't trigger, wouldn't work

i need determine if mouse on div @ specific point in time, if has moved or not starting point

all of hunting has found onmousover, , nothing see if mouse happens there begin with

i don't have javascript skills determine overall coords of div, map mouse coords , see if fits there... believe need do

set flag true onmouseover , false onmouseleave. when countdown finishes if flag true on element.

html

<div id="div-name">the section of code working has countdown timer, when reaches 0 need know if mouse on specific box</div> <button id="notification" onclick="javascript: letscountit(5);">click start countdown</button> 

js

window.ev = false;  document.getelementbyid('div-name').onmouseover = function () {     window.ev = true;     console.log(window.ev); }  document.getelementbyid('div-name').onmouseout = function () {     window.ev = false;     console.log(window.ev); }  window.letscountit = function (cdtimer) {     cdtimer--;     document.getelementbyid('notification').innerhtml = cdtimer;      if (cdtimer == 0) {         if (window.ev === true) {             alert('over');         } else {             alert('not over');         }     } else {         settimeout(function(){letscountit(cdtimer);}, 1000);     } } 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -