I'm trying to figure out a way to get sub-elements within an element. The basic structure of the page is like this:
Using document.getElementsByName I can find the top level "location" element but when I call getElementsByName on that element it fails saying: "The object doesn't support this method". getElementsByTagName works on the element however the page is huge and I could potentially be looping through hundreds of elements. There could also potentially be 100+ Buildings on a page and looping through each of them to find the ones I want to update just feels ugly.HTML Code:<div name="Location"> <div name="Building"></div> <div name="Building"></div> <div name="Location"> <div name="Building"></div> <div name="Location"> <div name="Building"></div> <div name="Building"></div>
Ideally, what I'd like to do is something like document.getElementByName("Location").item(0).getElementByName("Building") but that doesn't appear to work. Does anyone know of a nicer way of doing this?


Reply With Quote
Bookmarks