这可能很简单,但我找不到解决方案。是否有可能(以一种简单的方式!)为这个图像悬停脚本添加一个 jquery 淡入和淡出效果?
$('img[data-hover]').hover(function() {
$(this)
.attr('tmp', $(this).attr('src'))
.attr('src', $(this).attr('data-hover'))
.attr('data-hover', $(this).attr('tmp'))
.removeAttr('tmp');
}).each(function() {
$('<img />').attr('src', $(this).attr('data-hover'));
});
<img src="image1.jpg" data-hover="image2.jpg">