javascript image mouseovers


/ Published in: JavaScript
Save to your folder(s)

Using CSS is, of course, the preferred method of performing mouseover image swapping, but it's good to have a few tricks up your sleeve. Here's one way of doing it with JS, but the images have to be pre-loaded, or else there'll be a slight lag in the image swap.


Copy this code and paste it in your HTML
  1. <a href="location.htm"
  2. onMouseDown="document.images['img01'].src='images/b1c.gif'"
  3. onMouseOver="document.images['img01'].src='images/b1o.gif'"
  4. onMouseOut="document.images['img01'].src='images/b1.gif'">
  5. <img border="0" name="img01" src="images/b1.gif">
  6. </a>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.