I have the following html and js. It switches from one image to to the other fine. But I'd like the images to fade in and fade out (cross fade? is that the term?). I did a search but haven't been able to adapt the other fade methods into mine for some reason. How can I accomplish this?
<li class="item">
<a href="/link.html" class="gallery-item">
<span>
<img src="/pic1-1.jpg" data-hover="pic1-2.jpg" width="243" height="243" />
</span>
</a>
</li>
Javascript below
$(function () {
$('.item img').each(function () {
$(this).data('original', this.src)
}).mouseenter(function () {
$(this)
.attr('src', $(this).data('hover'))
}).mouseleave(function () {
$(this)
.attr('src', $(this).data('original'))
})
})
Here's a fiddle: http://jsfiddle.net/9qGtv/52/
Thanks!