SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Java Menu

  1. #1
    SitePoint Enthusiast Star777Star's Avatar
    Join Date
    Apr 2010
    Location
    South Africa
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Java Menu

    Hello

    I have this javascript menu, using css and javascript, but i have a small thing im not sure of, i have the menu to open when u click it and then close and open another menu when the other one is clicked.

    but i want the menu to open when u click on it and then close when u click on it again.

    This is my code:
    Code:
    function initMenu() {
      $('#menu ul').hide();
      //$('#menu ul:first').show();
      $('#menu li a').click(a
        function() {		
          var checkElement = $(this).next();
    	  //checkElement.slideToggle('normal');
          if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
            return false;
            }
          if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
            $('#menu ul:visible').slideUp('normal');
            checkElement.slideDown('normal');
            return false;
            }
          }
        );
      }
    $(document).ready(function() {initMenu();});

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Regarding the title of your thread:

    JavaScript is not the same as Java

    i want the menu to open when u click on it and then close when u click on it again.
    It sounds like you want the toggle() method.

  3. #3
    SitePoint Enthusiast Star777Star's Avatar
    Join Date
    Apr 2010
    Location
    South Africa
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where I can i add the toggle() function in the current code, and have the buttons of the menu still open when clicked and when another button on the menu is clicked that one opens and the previous one closes?

    cause i got the toggle thing working, but then when you click another menu button the previous one stays open.


Bookmarks

Posting Permissions

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