Results 1 to 2 of 2
  1. #1
    LWCARAB is offline Member
    Join Date
    Apr 2008
    Rep Power

    Default Collapse all Divs


    I have some code which enables me to collapse and expand divs, I have got it to do what I want it to do in my html page but I now need a button that collapse all the expanded divs and have no idea where to start. Can anyone help? I've attached the html, css and js files.


    Attached Files Attached Files

  2. #2
    bobleny's Avatar
    bobleny is offline Member
    Join Date
    Apr 2008
    Rep Power


    I have three pieces of advice for you,
    First and foremost: This is a Java forum, not a JavaScript forum. Java vs. JavaScript

    Second, there are a lot of people like me, who won't download a zip file from a forum. I think it is a bad Idea.... So, it is best to simply place your code in the "code boxes" (Much like I have bellow). That makes it easier on the people who want to help you, which is a good thing.

    Third, so as not to sound like a mean and bitter old man, you use this code to collapse a <div> tag in JavaScript:
    Java Code:
    document.getElementById(id).style.display = "none";
    Where "id" is the id of the div tag you'd like to collapse. It simply tells the browser to hid the div tag, thus it disappears...

    You can initiate this with the onclick command.
    Java Code:
    Where "SomeFunction" calls the function that will collapse the div tag and "id" is the id of the div tag you'd like to collapse.

    The function might look something like this:
    Java Code:
    function SomeFunction(id)
        document.getElementById(id).style.display = "none";
    Each id must be unique!
    Last edited by bobleny; 04-15-2008 at 07:57 PM.
    -- --
    Cheer up, the worst has yet to come...

Posting Permissions

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