I'm trying to create a box that has two states:
(a) The box is a width of 70% (b) The box is a width of 10%
The user should be able to click the box to alternate between the two states, so if the box is in state 'a' then it will transition to state 'b' when clicked. If the box is in state 'b' it will transition to state 'a' when clicked and so on. I'm using the css below to set the initial state of the box:
#box1 {
position:relative;
left:0%;
top:0%;
width: 70%;
height: 100%;
background-color: #666;
z-index:4;
}
I'm using the javascript function below to allow the box to be clickable:
function slideLeft1(){
if(document.getElementById('box1').style.width='70%'){
document.getElementById('box1').style.width='10%';
}
else{
document.getElementById('box1').style.width='70%';
}
}
It's working to go from 70% to 20% but not the reverse, so the if statement works but not the else statement. Any ideas??