onmouseover event
Definition and usage
The onmouseover event occurs when the mouse pointer moves over an element or its child element.
Tip:This event is usually used with onmouseout-händelseUsed together, this event occurs when the user moves the mouse pointer out of the element.
Instance
Example 1
Execute JavaScript when the mouse pointer is moved over the image:
<img onmouseover="bigImg(this)" src="smiley.gif" alt="Smiley">
Example 2
This example demonstrates the difference between onmousemove, onmouseenter, and mouseover events:
<div onmousemove="myMoveFunction()"> <p id="demo">I will demonstrate onmousemove!</p> </div> <div onmouseenter="myEnterFunction()"> <p id="demo2">I will demonstrate onmouseenter!</p> </div> <div onmouseover="myOverFunction()"> <p id="demo3">I will demonstrate onmouseover!</p> </div>
Syntax
In HTML:
<element onmouseover="myScript">
In JavaScript:
object.onmouseover = function(){myScript};
In JavaScript, use the addEventListener() method:
object.addEventListener("mouseover", myScript);
Note:Internet Explorer 8 or earlier versions do not support addEventListener() method.
Technical details
Bubbling: | Stöd |
---|---|
Cancellable: | Stöd |
Event types: | MouseEvent |
Supported HTML tags: | All HTML elements except: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style> and <title> |
DOM-version: | Nivå 2-händelser |
Webbläsarstöd
Händelser | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
onmouseover | Stöd | Stöd | Stöd | Stöd | Stöd |