我如何向这段jQuery添加淡入淡出,或设置不透明度变化的动画?
谢谢
<script type='text/javascript'>
$(document).ready(function(){
$(".alain").hover(
function() {$(this).attr("src","images/rollovers/alain-rollover.png");},
function() {$(this).attr("src","thumbnails/alain-thumbnail.jpg");
});
});
</script>发布于 2013-07-01 06:15:05
淡出图像,更改源,淡入图像:
$(document).ready(function(){
$(".alain").on('mouseenter mouseleave', function(e) {
var src = e.type == 'mouseenter' ? 'images/rollovers/alain-rollover.png' : 'thumbnails/alain-thumbnail.jpg';
$(this).fadeOut('slow', function() {
$(this).prop('src', src).fadeIn('slow');
});
});
});jsbin
如果较旧的浏览器不是问题,那么添加和删除带有CSS3转换的类似乎更容易。
https://stackoverflow.com/questions/17395231
复制相似问题