Results 1 to 2 of 2

Thread: Start with div collapsed

  1. #1
    Join Date
    Oct 2013
    Location
    nyc
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Start with div collapsed

    Hello!

    I have a collapsible div on my site and it works perfectly EXCEPT
    I don't know how to modify it so that when the page is loaded or refreshed it STARTS with the div contracted.

    Here is the script:
    Code:
    <script type="text/javascript">
    $(document).ready(function(){
        //hide the all of the element with class msg_body
        $(".msg_body").show();
        //toggle the componenet with class msg_body
    $(".question").click(function () {
        if ($(this).next(".answer").is(":hidden")) {
            $(this).next(".answer").slideDown("slow");
            $(this).children('span').text('-Bio');
        } else {$(this).next(".answer").slideUp("slow");
            $(this).children('span').text('+Bio');
            
        }
    });
    });
    </script>
    Here is the site:
    rachelforshee.net
    Last edited by djr33; 11-01-2013 at 08:46 PM. Reason: remove hyperlink

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Two small changes:
    <div class="question" >
    <span>+Bio</span>
    </div>
    <div class="answer" style="display: none">Lorem ipsum dolor sit amet, consectetuer adipiscing
    elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
    aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci
    tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo
    consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate
    velit esse molestie consequat, vel illum dolore eu feugiat nulla
    facilisis at vero eros et accumsan et iusto odio dignissim qui blandit
    praesent luptatum zzril delenit augue duis dolore te feugait nulla
    facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil
    imperdiet doming id quod mazim placerat facer possim assum.</div>
    Good luck.

Similar Threads

  1. Switch Content Script II Start Collapsed?
    By Jez in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 09-25-2007, 08:02 PM
  2. CMotion Image Gallery II: start in various positions & auto start
    By wormann in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-23-2007, 05:00 AM
  3. Slashdot menu will not start collapsed
    By rogerwilco in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 02-12-2007, 06:52 AM
  4. Switch Content II script ... start collapsed?
    By Mayhem Design in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 12-20-2006, 01:22 PM
  5. Switch Content Script II - want to start with collapsed state?
    By joelnativeenergy in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 11-08-2006, 02:35 PM

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
  •