My code here is designed to have a slide menu pull out. For some reason, I cannot seem to grab the "left" styling property of my element with id "news". Here is my javascript:
var current;
var currentValue;
var motionDir = 1;
window.onload = slide;
function slide() {
current = document.getElementById('news'); //returns HTML Object div
currentValue = current.style.left; //returns blank
function move() {
if(motionDir == 1) {
if(currentValue !== '0%') {
currentValue = parseInt(currentValue.substring(0, currentValue.length - 1)) + 2;
current.style.left = currentValue + '%';
} else {
clearInterval(intervalID);
}
} else {
if(currentValue !== '-50%') {
currentValue = parseInt(currentValue.substring(0, currentValue.length - 1)) - 2;
current.style.left = currentValue + '%';
} else {
clearInterval(intervalID);
}
}
}
var intervalID = setInterval(move, 20);
}
Notice where I set the current andent currentValue variables. CurrentValue returns a blank value for whatever style property I try setting it to. If I do:
currentValue = current.style;
Then it outputs [OBbject CSS2Properties] and I am unsure why it does not say CSS3. Anyways, I am totally stumped and have spent an hour trying to debug this, but no luck. I can assure you that all the code runs fine and it is linked properly to the DOM.