Jquery FadeIn 图像悬停在 SwapSource 上



我想在第二张图像上进行淡入和淡出,但不确定在哪里编写函数

var sourceSwap = function(){
 var $this = $(this);
 var newSource = $this.data('alt-src');
  $this.data('alt-src', $this.attr('src'));
  $this.attr('src', newSource);
}
$(function(){
  $('img.xyz').hover(sourceSwap, sourceSwap);
}) ;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img class="xyz" data-alt-src="img/map.jpg" src="img/colourmap.jpg" width="95%" />

试试这个

$('.xyz').fadeIn(1500).delay(0).fadeOut(1500);
    $('.xyz').delay(1000).fadeIn(1500);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img class="xyz" data-alt-src="img/map.jpg" src="http://www.apicius.es/wp-content/uploads/2012/07/IMG-20120714-009211.jpg" width="50%" />

最新更新