Hi! I am trying to make an element shake, and I have tried to make a function in JavaScript, but it won't work.
Here is the test page, used only for testing. It is the Genious test div that I want to shake. Here is the code:
function Shake(Pow){
setTimeout("Shake(3);",100);
var co = 1;
switch(co){
case 1:
document.getElementById('genious').style.left-=Math.random()*Pow;
break;
case 2:
document.getElementById('genious').style.left+=Math.random()*Pow;
break;
case 3:
document.getElementById('genious').style.top-=Math.random()*Pow;
break;
case 4:
document.getElementById('genious').style.top+=Math.random()*Pow;
break;
}
if(co<4){
co++;
}else{
co = 1;
}
}
This is how I start it all:
<body onload="Shake(3);">
I get this notice in firebug:
Error in parsing value for 'left'. Declaration dropped.
So please take a overlook and tell me what I have done wrong! Thanks!