SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Collapse Div?

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2005
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Collapse Div?

    I need a code to make a div collapse and have other divs slide up rather than just disappear. My current code is:

    Code:
    function hideDiv(divId) {
    	divId.style.visibility = 'hidden';
    }
    e39m5

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You want the display property. What is divId? Is it a string or is it an object?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2005
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its the ID on my div.
    HTML Code:
    <div id="row_52" class="row">
    <span class="update">
    <img src="del.gif" onclick="hideDiv('row_52');">
    <BR>
    <div id="saving_52" style="display:none;">
    <img src="indicator.gif" width="16" height="16" border="0" align="absmiddle" />
    </div>
    </span>
    <span class="sideone">
    <textarea>
    asdfasdfasdf
    </textarea>
    </span><span class="sidetwo">
    <textarea>
    Text
    </textarea>
    </span>
    </div>
    <div class="spacer">&nbsp</div>
    </div>
    Hope that helps. I'm just getting started with JS and I have no idea if thats a string or an object. I'm guessing that its an object though. If theres only text would that make it a string?

    Thanks,
    e39m5

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a string. We use document.getElementById() to convert that string, that happens to be the ID of an element, into an element reference. Then we set its display property to "none" to hide it completely.

    Here's the function.
    Code:
    function hideDiv(divId) {
      document.getElementById(divId).style.display = 'none';
    }
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


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
  •