I'm trying to make a CSS and Javascript menu with current class
I want to build an app made in javascript, PHP, and CSS, but I'm stuck in a dumb place. I want to make a menu to load links in an iframe called "zero". And it works, now I want to make it so that when you clik on a link the background of the link goes blue, and when you click on another, the background goes back to white and that link goes blue, and so on. The dificult part is that I have all the links like this:
index.php?act=page_name, so they are actualy the same page, diferent portions of it, loaded in another iframe.
and I have a Javascript to do it :
function grafice() {
document.getElementById("grafice").setAttribute("class", "current");
window.open('index.php?act=grafice_comenzi','zero');
}
where "current" is like this :
#menucase ul.vert-one li a.current,ul.vert-one li a.current:hover
{
background:#80BFFF;
color:#333333;
border-top:solid 1px #0099FF;
border-bottom:solid 1px #0099FF;
}
How do I go next, I want when I click another link, something in Javascript to tell the previous link to go white again.
here's a link to my page so far :
http://www.guku.byethost31.com/temp/
can anyone help me please ?开发者_如何学Python
I'd to do this : Once a link is clicked, change it's background color to blue , while you change the background color of the rest of the links in the page to white. (elementName.style.background:....)
Another and less suggested option is creating an hidden input field, which in it you store the id of the link you clicked on. After clicking on another link, you can retrieve the id that's stored in the hidden field and change it's background color to white.
Good luck with this.
精彩评论