In JavaScript:
object.onmouseout = function(){
myScript};
This example uses the HTML DOM to assign an "onmouseover" and "onmouseout" event to a h1 element.
<!DOCTYPE html> <html> <body> <h1 id="demo">Mouse over me</h1> <script> document.getElementById("demo").onmouseover = function() {mouseOver()}; document.getElementById("demo").onmouseout = function() {mouseOut()}; function mouseOver() {//from w w w. jav a 2 s .c o m document.getElementById("demo").style.color = "red"; } function mouseOut() { document.getElementById("demo").style.color = "black"; } </script> </body> </html>
Bubbles: Cancelable: Event type: Supported HTML tags: | Yes Yes MouseEvent All HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
---|