i have a website that should dynamically change when a link is clicked. the css i use for the links is as following:
Code:
div#nav a {
display:block;
color:#1084aa;
text-decoration:none;
padding:.3em 1em;
margin:0 0 2px;
font:1.2em bold;
text-align:center;
}
div#nav a:hover {
color:#000000;
background-color:#1084AA;
}
a sample link in the xhtml looks like this:
Code:
<a href="#" onclick="changeTab('home','hcontent');" id="home">Home</a>
the javascript that applies here looks like this:
Code:
var lastTab = "home";
function changeTab(tab,section){
document.getElementById(lastTab).innerHTML =
document.getElementById(lastTab).style.color="#1084AA";
document.getElementById(tab).style.backgroundColor="#1084AA";
document.getElementById(tab).style.color="#000000";
lastTab = tab;
document.getElementById('content').innerHTML = document.getElementById(section).innerHTML;
}
this works fine and everything is amazing but after a link is clicked and then another one is, the css hover effects no longer work because the element has the javascript style applied to it.
what would be the best way to "reset" the element's style to revert back to the css style so the hover will work?