The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Hide element again

  • # March 1, 2013 at 10:08 am

    Please help me – here :
    I’m slideTooggle some div but I can´t close the open div again?

    If I click nr. 1 I would like to close it again if I click it again

    # March 1, 2013 at 10:10 am

    I think you may have hit the wrong Codepen ‘mode’ there.

    I’m not seeing any CSS or JS….

    # March 1, 2013 at 10:14 am

    This line

    $(‘.arter-all > div’).hide();

    is causing your div#xx- to hide before it is toggled; therefore, when it is toggled it is only toggled on.

    Remove that line so that toggle can work the way you want it to.

    # March 1, 2013 at 10:52 am

    If I remove that line all the div would be open at once …there must be only one at a time open

    strange ???

    # March 1, 2013 at 4:50 pm

    This reply has been reported for inappropriate content.

    Collaborate view… this is normal view:

    Quick and dirty solution, exclude clicked element from the hide function: $('.arter-all > div').not('div#xx-'+elementClassName).hide();, better would be imho to keep track of which element is open and base what happens on if an element is already open or not.

    # March 1, 2013 at 5:03 pm


    Cool …this is working …. thanks :-)

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed