Old 07-05-2008, 11:36   #1 (permalink)
adras
Zły
 
adras's Avatar
 
Join Date: May 2004
Location: Toronto, Canada
Posts: 1,866
Send a message via MSN to adras
css javascript

I have this in the CSS:
HTML Code:
#menu li { some styles here }

HTML:
HTML Code:
<div id="menu"> <ul> <li>item1</li> <li>item2</li> ... </ul> </div>


My question is how do I access the <li> inside the menu ID div with Javascript, I need to change the background-color for it?
__________________
  Reply With Quote
Old 07-05-2008, 11:45   #2 (permalink)
weldo
now with added beard
 
weldo's Avatar
 
Join Date: Mar 2004
Location: Liverpool
Posts: 4,963
why not just specify another menu id or ul class ??
__________________
fuck signatures
  Reply With Quote
Old 07-05-2008, 11:46   #3 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,854
Fwiw…

Code:
document.getElementById('menu').getElementsByTagName('li')[x]
…where x is the index number for the particular li item you wish to address.


Note: indexes start at 0, so…

The first will be:
Code:
document.getElementById('menu').getElementsByTagName('li')[0]

The second will be:
Code:
document.getElementById('menu').getElementsByTagName('li')[1]

etc…



However, in case this is what you're trying to do…

Highlighting current page with CSS / journal / hicksdesign
  Reply With Quote
Old 07-05-2008, 11:59   #4 (permalink)
adras
Zły
 
adras's Avatar
 
Join Date: May 2004
Location: Toronto, Canada
Posts: 1,866
Send a message via MSN to adras
Thank you sir, this works like a charm!
__________________
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8