ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

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.

No comments:

Post a Comment