标签: javascript jquery fadein fadeout
如何让它在鼠标悬停时淡出并在mouseleave上再次淡入? My jsFiddle
$(function() { var box = $('#box'); box.on('mouseover', function() { box.fadeOut(500); }); box.on('mouseleave', function() { box.fadeIn(500); }); });
答案 0 :(得分:2)
$(function() { $('#box').on('mouseenter mouseleave', function() { $(this).stop().fadeToggle(); }); });
FIDDLE
答案 1 :(得分:1)
试试这个:
$(function() { var box = $('#box'); box.hover(function() { $(this).fadeOut(500); }, function() { $(this).stop().fadeIn(500); }); });
请参阅此fiddle