/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
window.addEvent('domready', function() { $$('img.mo').each(function(img) { var src = img.getProperty('src'); var extension = src.substring(src.lastIndexOf('.'),src.length) img.addEvent('mouseenter', function() { img.setProperty('src',src.replace(extension,'-mo' + extension)); }); img.addEvent('mouseleave', function() { img.setProperty('src',src); }); }); }); //Usage: <a href="/"><img src="/graphics/sugar.jpg" alt="Sugar" class="mo" height="50" width="150"></a>
URL: http://davidwalsh.name/sugar/mootools/page/3