Posted By

gbot on 03/08/08


Tagged

image mouseover mootools rollover


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

gbot
gismo
stephenns


MooTools image rollover


 / Published in: JavaScript
 

URL: http://davidwalsh.name/sugar/mootools/page/3

  1. window.addEvent('domready', function() {
  2. $$('img.mo').each(function(img) {
  3. var src = img.getProperty('src');
  4. var extension = src.substring(src.lastIndexOf('.'),src.length)
  5. img.addEvent('mouseenter', function() { img.setProperty('src',src.replace(extension,'-mo' + extension)); });
  6. img.addEvent('mouseleave', function() { img.setProperty('src',src); });
  7. });
  8. });
  9.  
  10. //Usage:
  11.  
  12. <a href="/"><img src="/graphics/sugar.jpg" alt="Sugar" class="mo" height="50" width="150"></a>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: gbot on March 8, 2008

Usage:

Posted By: gbot on March 8, 2008

[code][/code]

Posted By: GenoGod on February 16, 2009

The correct URL to the original is http://davidwalsh.name/mootools-image-mouseovers to maybe save someone some time.

Thanks for sharing this though!

You need to login to post a comment.