Grow your CSS skills. Land your dream job.

Show Hide Div modification

  • # January 2, 2013 at 10:51 am

    Hi All -

    I’ve recently come across this solution to the show/hide div problem: http://css-tricks.com/forums/discussion/19000/show-hide-div-with-toggle-text-help/p1

    The solution from SgtLegend (http://jsfiddle.net/wGbh5/1/ ) works brilliantly, but I have one problem.

    For this solution, it seems that the toggle link must be directly above the div it shows and hides in the html, or it won’t work.

    For example, this works:

    Show

    *** content ***

    However, if I place a div between the two lines:

    Show

    *** content ***

    It no longer works. Basically, what I need to do is have the link and the relevant div that it shows and hides in different parts of the HTML document.

    I’m sure the solution is simple, but I’m a total beginner.

    Many thanks,
    John

    # January 2, 2013 at 11:25 am

    Take a look at the toggle function of the official jQuery manual – this is covered pretty well. Also, I don’t like using a links to toggle content – you’re best off using a span imo as essentially if you use a link you’re linking to nothing.

    # January 2, 2013 at 12:42 pm

    [Create a CodePen or it didn’t happen](http://codepen.io)

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".