Using alternate data attributes for image rollovers, as outlined here: Best way to do image rollovers? and I can't figure out how to add a fade into attr swap.
Basically, on hover the img src changes, and that works perfectly. But is there a way to make it fade in/out?
$(function(){
$('img.rollover').hover(function(){
var e = $(this);
e.data('originalSrc', e.attr('src'));
e.attr('src', e.attr('data-rollover'));
}, function(){
var e = $(this);
e.attr('src', e.data('originalSrc'));
}); /* a preloader could easily go here too */
});
Jsfiddle here: http://jsfiddle.net/dtPRM/1/
Seems like a case for fadeToggle, but I've tried it in a couple places to no avail.
Also confused about the comma separated function on line six, though it seems to denote Not hovering.
Thanks