0

I'm using the following code to swap <div> contents. It functions properly with the exception of the mousein and mouseout behavior of the boxes, which shows the wrong one. The class name "flipped" has display set equal to none. Should I check state, use setTimeout() or another method to prevent this behavior?

The html

<div class="videobox">
        <div class="unflipped">
            <img src="videoprop.jpg">
            <div class="desc_over">This is a description! Video Contains This!</div>
        </div>
        <div class="flipped">This what displays when flipped 1!</div>
    </div>

The jQuery

$(".videobox").hover(function(){
            $(this).children(".unflipped:first").fadeOut("fast",function(){
                $(this).next(".flipped:first").fadeIn("fast");
            });         
        },function(){           
            $(this).children(".flipped:first").fadeOut("fast",function(){
                $(this).prev(".unflipped").fadeIn("fast");
            }); 
        });
element119
  • 7,475
  • 8
  • 51
  • 74
Codex73
  • 5,690
  • 11
  • 56
  • 76

1 Answers1

0

Try separating them:

$('.videobox').find('.unflipped').mouseenter(function() {
    $(this).fadeOut("fast", function() {
        $(this).next(".flipped").fadeIn("fast");
    });
});
$('.videobox').find('.flipped').mouseleave(function() {
    $(this).fadeOut("fast", function() {
        $(this).prev(".unflipped").fadeIn("fast");
    });
});
Mark Schultheiss
  • 32,614
  • 12
  • 69
  • 100