Jump to content

Unresponsive script


shadowayex

Recommended Posts

I have written a small script that is supposed to set the css top property of list items to that of the parent list item's top. The script looks like this:

			function position(object)			{				var items = object.childNodes;				for (i = 0; i < items.length; i++)				{					if (items[i].nodeName.toLowerCase() == "li")					{						items[i].style.top = object.offsetTop + "px";					}				}			}			window.onload = function()			{				var nav = document.getElementsByTagName("ul")[0];				var items = nav.childNodes;				for (i = 0; i < items.length; i++)				{					if (items[i].nodeName.toLowerCase() == "li")					{						position(items[i]);					}				}			}

I'm rather tired at the moment, and I cannot see anything wrong with this bit of code, although there is obviously something wrong. Does anyone see it?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...