0

I've got:

<div class='someclass'>Text</div>
<div class='otherclass'>Other Text</div>
<style>
    .someclass{
        width:400px;
        height:200px;
    }
    .otherclass{
        width:400px;
        height:200px;
        display:none;
    }
</style>

$('.someclass').mouseover(function(){
    $('.otherclass').fadeIn();
});
$('.someclass).mouseout(function(){
    $('.otherclass').fadeOut();
});

But I dont want second div to fade out if the cursor goes over this second div.

I can use

$('.someclass,.otherclass').mouseover(function(){
    $('.otherclass').fadeIn();
});
$('.someclass,.otherclass').mouseout(function(){
    $('.otherclass').fadeOut();
});

but it blinks by crossing from one div to another.

I think, I can use timeouts, but is there a better way? Thx!

1
  • Solved. I've just had to use mouseleave instead of mouseout. It works with position:absolute if nested. Commented Mar 14, 2012 at 19:23

3 Answers 3

1

I'm guessing that you're using this for a nav submenu or something similar.

I would suggest nesting .otherclass within .someclass.

Sign up to request clarification or add additional context in comments.

1 Comment

yes, it's about submenu, but the second div has position:absolute, so the first's div dimensions does not change, when second div fades in...
1

Can you wrap the two DIVs in another element and put the hover function on that outer element. That should cover the time when you are between the two.

Comments

1

put 'otherclass' into 'someclass' and set in someclass min-height:200px;

<div class="someclass">
 <div>Some text</div>
 <div class="otherclass">text</div>
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.