I have a div with id="pkg1" what I intend this script to do is animate the div and see it raise up the page when i press a button with onclick="raise()".
Right now it's just going straight to top=10px without any animation effect. Any ideas what I'm doing wrong?
var topPos = 120;
function raise()
{
var pkgStyle = document.getElementById("pkg1").style;
var topPos = topPos - 1;
if (topPos > 10)
{ pkgStyle.top = topPos + "px";
setTimeout(raise(), 1000);
}
else { pkgStyle.top = 10 + "px"; }
}