[jQuery] Automatic on-hover for images

[jQuery] Automatic on-hover for images

This script automatically changes images with class "Hover" on mouser
hover (for menus etc.)
FILES:
test.gif
test_over.gif
HTML:
<img src="test.gif" class="Hover"/>
JS:
$.auto.hover = {
init: function() {
$('IMG.Hover')
.bind('mouseover', this.enter)
.bind('mouseout', this.exit)
.each(this.preload);
},
preload: function() {
this.preloaded = new Image;
this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
},
enter: function() {
this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
},
exit: function() {
this.src = this.src.replace(/^(.+)_over(\.[a-z]+)$/, "$1$2");
}
};
$(document).ready($.auto.hover.init);
--
MichaƂ Tatarynowicz
Sputnik!
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/