How do you set an interval inside of an event?
switch(event.keyCode) { //case(40): // if(bottom < 406) //{ // el.style.color = "black"; //el.style.top = 8 + top; //} //break; // case(38): // if(top !=0) // { // el.style.top = top - 8; //} // break; case(37): if(left > 0) { el.style.left = left - 8; } break; case(39): if(right < 512) { el.style.left = left +8; } break; case(32): //space { var intervalMain = setInterval(jump, 10); } } I go into my jump function and try to clear this interval. I get the message that intervalMain is not defined. Why is that? intervalMain is a global variable.