I can't use else
in my script; how can I implement an if else
statement without using else
?
I'm trying to resize a div:
function hideTable(){
var table = document.getElementById('PDemo');
if(table.style.width == "50%") table.style.width = "150px";
if(table.style.width == "150px") table.style.width = "50%";
}
This script doesn't work because as soon as the first if
statement is executed, the condition for the second if
statement becomes true, so that executes too, and thus nothing changes.