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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    120
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Can't make script close link.

    Hi.

    I have been trying to find a how to make my script give me the option to click link to close it after link is clicked open.

    Currently can only click open. Doesn't work if click I on it after it opens wan't to click it closed.

    $('.nav-show').hide();

    $("li:has(ul)").click(function(){

    $("ul",this).slideDown();
    });

  2. #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    10,012
    Thanks
    6
    Thanked 1,180 Times in 1,151 Posts
    Code:
    $("li:has(ul)").click(function(){
      if($(this).hasClass('open')) {
        $(this).removeClass('open').find('ul').slideUp();
      }
      else {
       $(this).addClass('open').find('ul').slideDown();
      }
    });

  3. Users who have thanked VIPStephan for this post:

    riwakawd (10-28-2013)

  4. #3
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    120
    Thanks
    22
    Thanked 0 Times in 0 Posts
    Thanks for that. was using my old code just now starting to learn more java script and php.


 

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
  •