/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
window.addEvent('domready', function() { //preload images var aPreLoad = new Array(); var aPreLoadi = 0; //do rollover $$('img.roll', 'input.roll').each(function(el){ //let's preload aPreLoad[aPreLoadi] = new Image(); aPreLoad[aPreLoadi].src = el.src.replace(el.src.replace('_off_', '_on_')); aPreLoadi++; el.addEvent('mouseover',function(){ this.setAttribute('src',this.src.replace('_off_', '_on_')); }); el.addEvent('mouseout',function(){ this.setAttribute('src',this.src.replace('_on_','_off_')); }); }); }); window.addEvent('domready',function() { $each($$('.fade'), function(el) { var original = el.getStyle('color'); var morph = new Fx.Morph(el,{ 'duration':'300' }); el.addEvents({ 'mouseenter' : function() { morph.start({ 'color':'#ff8c00' }) }, 'mouseleave' : function() { morph.start({ 'color': original }) } }); }); });
Comments
