I need a code to make a div collapse and have other divs slide up rather than just disappear. My current code is:
e39m5Code:function hideDiv(divId) { divId.style.visibility = 'hidden'; }
| SitePoint Sponsor |



I need a code to make a div collapse and have other divs slide up rather than just disappear. My current code is:
e39m5Code:function hideDiv(divId) { divId.style.visibility = 'hidden'; }
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.



Its the ID on my 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?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"> </div> </div>
Thanks,
e39m5
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