MooTools image rollover


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



Copy this code and paste it in your HTML
  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>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.