Ok I previously asked how to do a javascript image hover effect, however the effect doesn't allow the images to be previously preloaded. I was wondering if anyone could help me improve/make new script that will preload the images requested. Here is the code:
$('#nav li a img').each(function() {
var originalSrc = this.src,
hoverSrc = originalSrc.replace(/\.(gif|png|jpe?g)$/, '_hover.$1');
$(this).hover(function() {
this.src = hoverSrc;
}, function() {
this.src = originalSrc;
});
});
{}. You can also indent the code by 4 spaces.