PDA

View Full Version : onmouse over element



.alias.
03-26-2006, 06:22 PM
i need to be able to find out if the mouse is over an element.

would it be something like

doument.getElemntById('id').mouseover

thanks for any help

jscheuer1
03-26-2006, 06:28 PM
doument.getElemntById('id').onmouseover=function(){alert('Ta Da!');}

.alias.
03-26-2006, 06:32 PM
thanks but i need to be able to use it in if


if (doument.getElemntById('id').mouseover)
{
alert('ok')
}
else
{
alert('end')
}

jscheuer1
03-26-2006, 06:48 PM
Unless you want to track the position of the mouse over the document which is rather resource intensive but can be done, comparing it to the x, y, rightedge and bottomedge of your element, you can just create a global variable:


var overel=0;

Then either through script, as in my previous example, or in the HTML code, assign onmouseover and onmouseout events to your element which include (they can do other things as well) for example in HTML:


<div onmouseover="overel=1" onmouseout="overel=0">Content for this division</div>

Then you can do:


if (overel)
{
alert('ok')
}
else
{
alert('end')
}

.alias.
03-27-2006, 02:43 PM
WOW i was dumb when i posted this question lol. normal i would of just used your first reply and done what you did in you second post. thanks anyway