inherit
130228
GamingMedley charles.stover
0
Nov 18, 2012 0:12:30 GMT -8
Charles Stover
PM me for Arcade or ShoutBox support
1,731
August 2008
gamechief
|
Post by Charles Stover on Mar 30, 2009 21:28:15 GMT -8
<script type="text/javascript">//<![CDATA[ // Expand/Collapse Lists by Charles Stover // http://gamingmedley.com expandCollapse = function(list) { var lis = list.getElementsByTagName("li"), t, temp, x = 0, y; for (t = 0; t < lis.length; t++) { if (lis[t].getElementsByTagName("ul")[0]) { lis[t].getElementsByTagName("ul")[0].style.display = "none"; lis[t].style.cursor = "pointer"; } else lis[t].style.cursor = "default"; lis[t].onclick = function() { temp = this.parentNode.parentNode; y = 0; while (temp.nodeName != "BODY") { temp = temp.parentNode.parentNode; y++; } if ((this.getElementsByTagName("ul")[0]) && (y >= x)) { x = y; temp = this.getElementsByTagName("ul")[0]; if (temp.style.display == "none") temp.style.display = "block"; else temp.style.display = "none"; } else if (y >= x) this.parentNode.style.display = "none"; if (!y) x = 0; } } } //]]></script> This is a script I've had for a while, but never shared until now. To use it, simply expandCollapse(theElementToCollapse); Most easily used if you assign the element an ID, then you can just document.getElementById. You can view a demo here. Hopefully a lotta you will find it useful. I do. Feel free to increase by PR by linking to GamingMedley if you use it. ^_^
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Mar 31, 2009 10:02:58 GMT -8
Good stuff, added to the Snippet page.
|
|