【发布时间】:2017-10-31 23:31:58
【问题描述】:
我想在第二张图片上做一个淡入淡出,但不知道在哪里写函数
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%" />
【问题讨论】:
标签: jquery html image fadein swap