1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Collapse and Expand Accordion Header

Discussion in 'Programming' started by bvfrezz, Oct 22, 2010.

  1. #1
    I have been trying to find a script or tutorial for a menu that will expand and collapse in the header. I have attached two images that show a view when the menu is open and closed. Has anyone seen a script or tutorial showing how this is done? Any tips would be appreciated.

    Closed Menu
    [​IMG]

    Open Menu
    [​IMG]
     
    bvfrezz, Oct 22, 2010 IP
  2. wing

    wing Active Member

    Messages:
    210
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #2
    How about the jquery effect, animate?
    Check the manual ( effects > animate ) on jquery 's website for examples.

    :)
     
    wing, Oct 22, 2010 IP
  3. bvfrezz

    bvfrezz Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I looked at the slideToggle function earlier and this is what I can use. Was looking for a specific example or tutorial for using the slideToggle feature. I couldn't find many tutorials for this function.
     
    bvfrezz, Oct 22, 2010 IP
  4. wing

    wing Active Member

    Messages:
    210
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #4
    OK, how about this then.
    The Jquery function toggle(), can be used to alternate between various effects or whatever.

    In this case, you need some kind of selector, like for instance a class name or id: $('.some_class') or $('#some_id').

    Lets say you want to use something with the class "the_trigger" as the trigger, and you want to expand/collapse something with the class "to_be_toggled" every other click on your trigger.

    Then your code could look like this:
    $(function() {
    
     $('.the_trigger').toggle(
     function () {
      $('.to_be_toggled').slideToggle(300);
     },
     function () {
      $('.to_be_toggled').slideToggle(300);
     });
    
    });
    Code (markup):
    When you click on the element with the class "the_trigger" the element with the class "to_be_toggled" will expand and collapse with a pretty animation.

    :)
     
    wing, Oct 23, 2010 IP