HTML Setting Active with different background colour
Posted
by danit
on Stack Overflow
See other posts from Stack Overflow
or by danit
Published on 2010-06-09T11:48:43Z
Indexed on
2010/06/09
11:52 UTC
Read the original article
Hit count: 186
Here is my HTML List:
<ul id="navlist">
<li class="item1"><a href="#">One</a></li>
<li class="item2"><a href="#">Two</a></li>
<li class="item3"><a href="#">Three</a></li>
<li class="item4"><a href="#">Four</a></li>
<li class="item5"><a href="#">Five</a></li>
<li class="item6"><a href="#">Six</a></li>
</ul>
Each .itemx
has a different background colour, so I need the active state to take into account the class
.
Obviously something like:
<li class="item6" id="active"><a href="#">Six</a></li>
#active.item6 {
background: red;
}
Would work but IE6 doesnt like chained items in CSS so doesnt work when other items are set out in the CSS.
Can I do this with jQuery where each item has a different background colour when 'active?
© Stack Overflow or respective owner