Created
February 15, 2012 15:13
-
-
Save ChrisMoney/4b99319e2753bf00559b to your computer and use it in GitHub Desktop.
Javascript --Mouseover
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Mouseover_Image | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
| "http://www.w3.org/TR/xhtmll/DTD/xhtmll-tansitional.dtd"> | |
| <html> | |
| <head> | |
| <title>Usig the srcElement Property</title> | |
| <script type = "text/javascript"> | |
| function image_eventHandler() { | |
| var sourceElement = window.event.srcElement; //Get the element. | |
| var eventType = window.event.type; //Get the type of event. | |
| if (eventType == "mouseover") (//The mouse rolled over theimage. | |
| sourceElement.src = "o.gif"; //so change the image's src property. | |
| } | |
| if (eventType == "mouseout") (//The mouse moved out. | |
| sourceElement.src = "x.gif"; //So change it back to the original. | |
| } | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <img src ="x.gif" onmouseover = "image_eventHandler()" | |
| onmouseover = "image_eventHandler()" /> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment