$('div').on('mouseover mouseout', function(e) { $(this).stop().animate({opacity: +(e.type == 'mouseout'}), 500); });