Jump to content

Unresponsive script


shadowayex
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...