Changing A Different Class Display on Hover with Jquery

Posted by John K on Stack Overflow See other posts from Stack Overflow or by John K
Published on 2010-04-24T18:49:29Z Indexed on 2010/04/24 18:53 UTC
Read the original article Hit count: 222

Filed under:
|
|
|
|

Ok, here's what I'm trying to do. I have a DIV box with a child element set with DISPLAY: NONE;. I'm trying to use Jquery so that when the mouse enters the parent DIV box, the child element is made visible, and then hides when the mouse leaves the parent DV. There will be multiple divs on the page with these classes. For some reason it's not working. Any ideas? Here's my code:

HTML:

<div class="parent">  
     <span class="handle" style="display: none;">My Handle</span>
     <p>Child Text</p>
</div>

Javascript:

$(document).ready(function () {
    $('.parent').mouseenter(function(){
        $(this).next('.handle').show();
    });
    $('.parent').mouseleave(function(){
        $(this).next('.handle').hide();
    });
})

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about mouseenter