JAVAEOC
04-21-2004, 02:51 AM
How could I use JS to select a <ul> element which is inside a <li> element?
|
||||
Use JS to select a li inside a liJAVAEOC 04-21-2004, 02:51 AM How could I use JS to select a <ul> element which is inside a <li> element? brothercake 04-21-2004, 03:32 AM You can use getElementsByTagName from any root element, so if you start from your list-item then the nested <ul> will be [0] in that array: var submenu = listItem.getElementsByTagName('ul')[0]; Assuming you know it will be there. If you don't then you can query the length property of that collection before grabbing the object from it, or not: var menus = listItem.getElementsByTagName('ul'); var submenu = (menus.length > 0) ? menus[0] : null; JAVAEOC 04-21-2004, 12:12 PM the listItem, would this be something like: document.getElementById('Menu') cause that doesnt work for me, :( JAVAEOC 04-21-2004, 01:12 PM I give up: Brother cake, how did you manage to build you udm on this basis?: <ul> <li><a href="#">lorem</a></li> <li><a href="#">lorem</a></li> <li><a href="#">lorem</a></li> <li> <a href="#">adipiscing</a> <ul> <li><a href="#">dolor</a></li> <li><a href="#">elit</a></li> <li><a href="#">ipsum</a></li> <li><a href="#">Donec</a></li> </ul> </li> </ul> thanks alot, I have been trying to select the UL with js, when i hover over the LI, but then the A tag gets in the way (which is in the LI tag), but then i no longer hover over a li tag, i hover of the a tag... soo please tell me how you manage to do it.... thanks alot :D brothercake 04-25-2004, 08:20 AM Well have you seen the prototype I made at http://www.brothercake.com/scripts/listmenu/ ? That'll give you the basic event handling model. JAVAEOC 04-25-2004, 02:49 PM thanks, I am working on MY menu right now, I thought it can do everything yours can do but then i saw that i have about 1/10000 of your code, about 10 lines of JS, I MUST be missing something :D ....dude, very nice menu :D, love it..... brothercake 04-25-2004, 05:22 PM Nah that link is to a much earlier version - it only has a dozen lines of scripting in it. I only suggested you look at it to see how I bound the event handlers to the list items and managed the flow of events. JAVAEOC 04-25-2004, 09:00 PM Nah, thanks alot brothercake, but that script is way over my head :D |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum