I'd suggest binding the 'mouseenter'
handler on the '#popup'
element alone.
Or add a wrapper around the images, and target this wrapper :
<div id="images">
<img id="img_then" ...>
<img id="img_now" ...>
</div>
$("#images").on("mouseenter", function(){
if ($("#img_now").is(":visible")) {
$("#img_then").fadeIn(2000);
$("#img_now").fadeOut(2000);
}
else if ($("#img_then").is(":visible")) {
$("#img_then").fadeOut(2000);
$("#img_now").fadeIn(2000);
}
});