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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Athens
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Small script help

    Hello everyone,

    I got this small script using jQuery that slides down a <ul> when an image is clicked. I was wondering how I could make the ul slide back when the mouse moves away from it and not demand from the user to click on the image again. I tried changing click() to mouseover() but that of course doesn't take into account the ul.

    PHP Code:
    <script type="text/javascript">
    $(
    document).ready(function () {
        $(
    'img.menu_class').click(function() {
        $(
    'ul.the_menu').slideToggle('medium');
        });

    }); 
    Thanks in advance!

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,950
    Thanks
    9
    Thanked 724 Times in 718 Posts
    This would hide the menu on mouseout in addition to your click event:

    Code:
        $('img.menu_class').mouseleave(function() {
        $('ul.the_menu').slideUp('medium');
        });


  •  

    Posting Permissions

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