Home

Tuesday, March 22, 2011

CHANGING IMAGE ON MOUSE HOVER IN ANCHOR TAG

Below code is used to change IMAGE in anchor code on Mouse Hover.

Include Below SCRIPT:
<script language="javascript" type="text/javascript">
/**
 * flip(imgName, imgSrc) sets the src attribute of a named
 * image in the current document. The function must be passed
 * two strings. The first is the name of the image in the document
 * and the second is the source to set it to.
 **/
function flip(imgName, imgSrc){
   if (document.images){
      document[imgName].src = imgSrc
   }
}
</script>


Now you code for ANCHOR Tag will be:
<a HREF="nextPage.html" onMouseOver="flip('Register', 'images/test_hover.gif')"
     onMouseOut ="flip('Register', 'images/test.gif')">                               
     <img src="images/test.gif" alt="Register" name="Register" width="185" border="0">

</a>

Note: Here test.gif is visible by default and test_hover image will be visible on Mouse Hover.

1 comment:

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.

    ReplyDelete

rathoddhirendra.blogspot.com-Google pagerank and Worth