Return to Snippet

Revision: 5425
at March 8, 2008 10:48 by gbot


Updated Code
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>

Revision: 5424
at March 8, 2008 10:48 by gbot


Updated Code
# 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>

Revision: 5423
at March 8, 2008 10:45 by gbot


Initial Code
# 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); });  
# });  
# });

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

Initial Description

                                

Initial Title
MooTools image rollover

Initial Tags
image

Initial Language
JavaScript