Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Created February 15, 2012 15:13
Show Gist options
  • Select an option

  • Save ChrisMoney/4b99319e2753bf00559b to your computer and use it in GitHub Desktop.

Select an option

Save ChrisMoney/4b99319e2753bf00559b to your computer and use it in GitHub Desktop.
Javascript --Mouseover
//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