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,473
  • 7
  • 50
  • 72
Codex73
  • 5,611
  • 9
  • 55
  • 75

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
  • 30,473
  • 11
  • 66
  • 95