i am doing a site with 2 navigations (navs) including links, each of them in another div.
When a link is clicked it should change its background image in the css (change class). And only one link of its class can change the background.
In the second nav there is one link which is also included in nav 1. Also are in the second nav two different background images to "toggle".
I already have accomplished the first nav, but I do not know how to include the second one. In the second one is the problem that two links should not change their background at the same time.
The site: http://enlifer.de/test25/zp-kazachkova.html
The second nav is at the height of the logo. If "Leistungen" is clicked in the second nav, the first one should also change its default background and vice versa.
Following code is relevant.
First nav
<navigation>
<ul id="nav">
<li class="link" onclick="mark(this)"> <a href="#" class="textlink">Kontakt</a> </li>
<li class="link" onclick="mark(this)"> <a href="#" class="textlink">Anfahrt</a> </li>
<li class="link" onclick="mark(this)"> <a href="#" class="textlink">Leistungen</a> </li>
<li class="link" onclick="mark(this)"> <a href="#" class="textlink">Praxisteam</a> </li>
</ul>
</navigation>
Second nav
<up>
<ul id="up">
<li class="uplink-l" onclick="l_mark(this)"> <a href="#" class="uptextlink-l">Leistungen</a> </li>
<li class="uplink-i" onclick="i_mark(this)"> <a href="#" class="uptextlink-i">Impressum</a> </li>
</ul>
</up>
JavaScript
<script type="text/javascript">
function mark(cell)
{
for(i=0; i <
document.getElementById("nav").getElementsByTagName("li").length; i++)
{
document.getElementById("nav").getElementsByTagName("li")[i].className="link";
}
cell.className="linkactive";
}
function l_mark(cell)
{
for(i=0; i <
document.getElementById("up").getElementsByTagName("li")[0].length; i++)
{
document.getElementById("up").getElementsByTagName("li")[0][i].className="uplink-l";
}
cell.className="uplink-l-active";
}
function i_mark(cell)
{
for(i=0; i <
document.getElementById("up").getElementsByTagName("li")[1].length; i++)
{
document.getElementById("up").getElementsByTagName("li")[1][i].className="uplink-i";
}
cell.className="uplink-i-active";
}
window.onload = setActive;
</script>
Thanks!
i
– ThiefMaster♦ Mar 18 '12 at 18:23