I have the following JavaScript/JQuery code which should make the div SideBar
appear on the screen and become 1/5th the size of the body. I'm getting no errors in Firefox/Chrome console, and havve no idea why it isn't working. If I move the body of my first toggle method into the method itself it works fine, so I'm assuming I'm using the toggle method wrong.
var bodyHeight = $(window).height();
var bodyWidth = $(window).width();
sideWidth = bodyWidth / 5;
function slideSideBar() {
$('#SideBar').toggle(
function() {
$("#SideBar").animate({
opacity: 0.6,
width: sideWidth
}, 600);
},
function() {
$("#SideBar").animate({
opacity: 0,
width: 0
}, 600);
});
}
The CSS is:
#SideBar {
height: 100%;
width: 0%;
opacity: 0;
font-family: Arial, Tahoma, Verdana;
color: white;
background-color: black;
}