Need some help with Navigation.
When I click on a div – i would like the background color to change to gray.
When I click on another Div – I would like the background to chnage to gray, however it will also need to change the previous div (or all divs in that class) to a white background.
Any suggestions?
<html>
<head>
<title>test</title>
<script type=”text/javascript”>
function highlight(currentdiv) {
document.getElementById(currentdiv).style.backgroundColor=’#CCC’;
}
</script>
<style type=”text/css”>
.mybox {
display:block;
background:#ffc;
padding:5px;
border:1px solid red;
width:100px;
height:35px; cursor:pointer;
}
</style>
</head>
<body>
<div id=”P1″ class=”mybox” onClick=”highlight(‘P1’)”>1</div>
<div id=”P2″ class=”mybox” onClick=”highlight(‘P2’)”>2</div>
<div id=”P3″ class=”mybox” onClick=”highlight(‘P3’)”>3</div>
<div id=”P4″ class=”mybox” onClick=”highlight(‘P4’)”>4</div>
<div id=”P5″ class=”mybox” onClick=”highlight(‘P5’)”>5</div>
</body>
</html>