Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2013
    Location
    Bristol, UK
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Keep div open when hovered over

    Hi,
    I'm using a bit of Jquery to open a div when hovered over.

    The problem is that when I move the mouse into the newly opened div it disappears again.

    I realise that this is because the hover rule is only applied to the first div.

    My question is what do I need to add in order to keep the div open when the mouse is hovered in it and also so it disappears when the mouse leaves the div.

    Any advice/pointers would be appreciated!

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,686
    Thanks
    25
    Thanked 656 Times in 655 Posts
    to open a div
    What does this mean???? maybe visible?
    With 8 posts under your belt you should realize that code is needed to get an answer.

    And I bet this can be done in css.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    New Coder
    Join Date
    Jan 2013
    Location
    Bristol, UK
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I did make a jsfiddle for it but forgot to post it. Woops.

    This is what i'm working with:

    http://jsfiddle.net/ENN2G/

    And yes, i'm sure it can be done in CSS.

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,686
    Thanks
    25
    Thanked 656 Times in 655 Posts
    I have done this before and thought it was easy, but have waisted the last two days getting nowhere. Then, while I was driving home from town my brain screamed Eureka and ran down the road naked.

    Change class="flyout" to an ID and put that div inside the socialhover div and we're good to go:
    Code:
    <script type="text/javascript">
    $(document).ready(function(){
    	$("#socialhover").hover(function(){
    		$('#flyout').slideToggle();
    	});
    });
    </script>
    </head>
    
    <body>
    <div id="socialhover">
        <a href="#">Follow Us</a>
    
    	<div id="flyout" class="hidden">
    	    <a href="#">Link 1</a><br>
    	    <a href="#">Link 2</a><br>
    	    <a href="#">Link 3</a><br>
    	    <a href="#">Link 4</a><br>
    	</div>
    </div>
    </body>


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •