Help with javascript cookie

I have javascript tree which is built and defined with list items

The ul’s gets the style property display= none when uncollapsed and no style when collapse. The idea is to remember the state of the tree. I want to do this by saving the style properties in a cookie. I got most of the cookie script working only i can’t seem to get the style properties and store them.

anyone help please, much appreciated

Here is the start of the javascript


var stateColl= document.getElementsByTagName("ul");
		for( i=0; i < stateColl.length;i++)
			{
				alert(stateColl[i]);
		}

and this how mu html looks like ;
for collapsed tree;

<ul>
  <li></li>
<li></li>
<li></li>
<li></li>
</ul>

for uncollapsed tree

<ul style="overflow: visible; display: none;">
  li></li>
<li></li>
<li></li>
<li></li>
<ul>

The style property is what you use to access style attributes.

For example, if el is the element:

el.style.overflow
or
el.style.display

i have tried this
var stateColl= document.getElementsByTagName(“ul”).getAttribute(“display”);

but doesn’t seem to be supported by browser

any suggestion ??

getElementsByTagName(“ul”) gives you an array-like collection.
You need to provide an array index (such as [0]) to reference only one single element.

i tried this;

var stateColl= document.getElementsByTagName(“ul”);
for( i=0; i < stateColl.length;i++)
{
var atributes= stateColl[i].getAttribute(“display”);

			alert(atributes+"&lt;br&gt;");
	
			
	}

but seem to get null as a result… but did find the amount of ul’s

display is not an attribute for the ul. Use the style property, like Paul wrote above.

stateColl[i].style.display