We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


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]

You need to login to post a comment.